我想在相同的窗口和相同的选项卡中打开一个链接,其中包含有链接的页面。
当我试图打开一个链接使用窗口。打开,然后在新选项卡中打开——而不是在同一窗口的同一选项卡中。
我想在相同的窗口和相同的选项卡中打开一个链接,其中包含有链接的页面。
当我试图打开一个链接使用窗口。打开,然后在新选项卡中打开——而不是在同一窗口的同一选项卡中。
当前回答
在html 5中,你可以使用历史API。
history.pushState({
prevUrl: window.location.href
}, 'Next page', 'http://localhost/x/next_page');
history.go();
然后在下一页中,您可以像这样访问状态对象
let url = history.state.prevUrl;
if (url) {
console.log('user come from: '+ url)
}
其他回答
你一定要用window.open吗?如果使用window.location="http://example.com"呢?
你可以这样做
window.close();
window.open("index.html");
它在我的网站上很成功。
这很简单。打开第一个窗口作为窗口。打开(url, < tabNmae >)
abc操作:window . open(“。com”、“myTab”)
下一个窗口。打开,使用相同的标签名,而不是_self, _parent等。
在html 5中,你可以使用历史API。
history.pushState({
prevUrl: window.location.href
}, 'Next page', 'http://localhost/x/next_page');
history.go();
然后在下一页中,您可以像这样访问状态对象
let url = history.state.prevUrl;
if (url) {
console.log('user come from: '+ url)
}
用这个:
location.href = "http://example.com";