使用JavaScript在新选项卡(而不是新窗口)中打开URL

使用JavaScript在新选项卡(而不是新窗口)中打开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.

CSS3提议 target-new ,但规范被放弃了

反向不是真的;通过在 window.open 的第三个参数中指定窗口的尺寸,可以在首选项用于标签时触发新窗口。

The reverse is not true; by specifying dimensions for the window in the third argument of window.open, you can trigger a new window when the preference is for tabs.