在新选项卡(而不是窗口)中打开 URL 的 Javascript

在新选项卡(而不是窗口)中打开 URL 的 Javascript

问题描述:

大家好.这里有一些条目需要解决方案来做与此相反的事情,而其他条目则模糊相关.其中一张海报询问如何在 Mozilla Firefox 上执行此操作.但实际上,firefox 会在调用 window.open() 时总是在新选项卡中打开 URL,除非您在其参数中设置窗口的大小.

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.

所以 Mozilla 和 Chrome 默认做我想要的.问题是:如何让 Internet Explorer 在新选项卡中打开我想要的 URL,而不是在新窗口中打开?

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?

提前致谢.

显而易见的答案是打开带有 target="_blank" 的链接.如您所说,Firefox 和 Chrome 将打开一个新标签页.

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

关于 IE - 行为取决于浏览器首选项.默认情况下(显然在 IE7+ 中)我相信行为被定义为打开新标签.如果用户决定行为应该是一个新窗口,那么你能做的就只有这么多了.

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.