在同一个窗口中并在同一个标​​签中打开网址 [英] Open URL in same window and in same tab

查看:107
本文介绍了在同一个窗口中并在同一个标​​签中打开网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我尝试通过使用链接打开链接时

我想在同一个窗口中打开链接,并在包含链接页面的相同选项卡中打开链接。 window.open ,那么它会在新标签页中打开,而不是在同一个窗口中的同一个标签页中。

解决方案

您需要使用name属性:

  window.open(https:// www.youraddress.com,_ self)

编辑:网址应该加上协议。没有它会尝试打开相关的网址。经过Chrome 59,Firefox 54和IE 11测试。

I want to open a link in the same window and in the same tab that contains the page with the link.

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.

解决方案

You need to use the name attribute:

window.open("https://www.youraddress.com","_self")

Edit: Url should be prepended with protocol. Without it tries to open relative url. Tested in Chrome 59, Firefox 54 and IE 11.

这篇关于在同一个窗口中并在同一个标​​签中打开网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆