在新标签页(而不是新窗口)中打开URL
我正在尝试在新标签页(而不是弹出窗口)中打开 URL 窗口.
I'm trying to open a URL in a new tab, as opposed to a popup window.
我看到了相关的问题,答案看起来像这样:
I've seen related questions where the responses would look something like:
window.open(url,'_blank');
window.open(url);
但是它们都不适合我,浏览器仍然尝试打开一个弹出窗口.
But none of them worked for me, the browser still tried to open a popup window.
作者无所不能,只能选择在新标签页中打开,而不是在新窗口中打开.这是用户首选项. (请注意,大多数浏览器中的默认用户首选项是针对新标签页的,因此在未更改首选项的浏览器中进行的琐碎测试不会证明这一点.)
Nothing an author can do can choose to open in a new tab instead of a new window; it is a user preference. (Note that the default user preference in most browsers is for new tabs, so a trivial test on a browser where that preference hasn't been changed will not demonstrate this.)
CSS3 proposed target-new, but the specification was abandoned.
反向不正确;通过在window.open()
的第三个参数中为窗口指定某些窗口功能,可以在选项卡的首选项时触发新窗口.
The reverse is not true; by specifying certain window features for the window in the third argument of window.open()
, you can trigger a new window when the preference is for tabs.