在新选项卡(而不是新窗口)中打开 URL [英] Open a URL in a new tab (and not a new window)
问题描述
我正在尝试在新标签页中打开一个 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 提议 target-new,但该规范已被放弃.
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.
这篇关于在新选项卡(而不是新窗口)中打开 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!