我想在相同的窗口和相同的选项卡中打开一个链接,其中包含有链接的页面。
当我试图打开一个链接使用窗口。打开,然后在新选项卡中打开——而不是在同一窗口的同一选项卡中。
我想在相同的窗口和相同的选项卡中打开一个链接,其中包含有链接的页面。
当我试图打开一个链接使用窗口。打开,然后在新选项卡中打开——而不是在同一窗口的同一选项卡中。
当前回答
Just Try in button.
<button onclick="location.reload();location.href='url_name'"
id="myButton" class="btn request-callback" >Explore More</button>
Using href
<a href="#" class="know_how" onclick="location.reload();location.href='url_name'">Know More</a>
其他回答
就像这样 _self window.open (" www.youraddress.com ", " ")
如果你有你的页面在“框架”那么 “Window.open(“logout.aspx”、“_self”)”
将被重定向到同一帧内。所以通过使用
"Window.open('logout.aspx','_top')"
我们可以加载页面作为新的请求。
你可以让它跳转到相同的页面而不指定url:
window.open('?','_self');
窗口。Open (url, wndname, params),它有三个参数。如果你不希望它在同一个窗口中打开,只需要设置一个不同的wndname。例如:
window.open(url1, "name1", params); // this open one window or tab
window.open(url1, "name2", params); // though url is same, but it'll open in another window(tab).
下面是关于window.open()的详细信息,你可以信任它! https://developer.mozilla.org/en/DOM/window.open
试试吧~~
在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)
}