Javascript to open URL within a new Tab (instead of a window)

六月ゝ 毕业季﹏ 提交于 2019-12-02 18:01:49

问题


Hey guys. There are a few entries here requiring solutions to do the opposite of this, and others vaguely related. In one of them, the poster asked how to do this on Mozilla Firefox. Actually though, firefox will always open the URL in a new tab when window.open() is called, unless you set the window's size within its parameters.

So Mozilla and Chrome do what I want by default. The question is: how do I get Internet Explorer to open the URL I want within a new tab, as opposed to doing it in a new window?

Thanks in advance.


回答1:


The obvious answer is to open the link with target="_blank". As you said, Firefox and Chrome will open a new tab.

Regarding IE - the behavior is up to browser preferences. By default (in IE7+ obviously) I believe the behavior is defined as open new tab. If the user decided the behavior should be a new window, there's only so much you can do about it.



来源:https://stackoverflow.com/questions/3272176/javascript-to-open-url-within-a-new-tab-instead-of-a-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!