在同一窗口和同一选项卡中打开 URL [英] Open URL in same window and in same tab
本文介绍了在同一窗口和同一选项卡中打开 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在包含该链接的页面的同一个窗口和同一个选项卡中打开一个链接.
I want to open a link in the same window and in the same tab that contains the page with the link.
当我尝试使用 window.open
打开链接时,它会在新选项卡中打开,而不是在同一窗口的同一选项卡中.
When I try to open a link by using window.open
, then it opens in new tab—not in the same tab in the same window.
推荐答案
需要使用name属性:
You need to use the name attribute:
window.open("https://www.youraddress.com","_self")
编辑:Url 应该加上协议.没有它会尝试打开相对 url.在 Chrome 59、Firefox 54 和 IE 11 中测试.
Edit: Url should be prepended with protocol. Without it tries to open relative url. Tested in Chrome 59, Firefox 54 and IE 11.
这篇关于在同一窗口和同一选项卡中打开 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文