【问题标题】:Open new window in background on在后台打开新窗口
【发布时间】:2018-06-29 15:31:26
【问题描述】:

我正在尝试在 Google Chrome 版本 62.0.3202.94 中在后台打开新窗口。我通过在记事本中键入并复制粘贴到 F12 开发人员控制台来运行代码。

这是我迄今为止尝试过的代码,改编自各种 Google 搜索结果:

var url = "https://stackoverflow.com/";

function test1(){
    var w = window.open(url);
    w.blur();
    window.focus();
}

function test2(){
    window.open(url);
    window.open().close();
}

function test3(){
    window.open(url, "s", "width= 640, height= 480, left=0, top=0, resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no").blur();
    window.focus();
}

然后我输入了 test1()test2()test3() 并按 Enter 键,但没有达到我想要的效果:新页面刚刚打开并获得焦点。

我能做到吗?


注意强调浏览器和版本。

【问题讨论】:

标签: javascript google-chrome window-object


【解决方案1】:

这仅适用于在后台打开新窗口,不适用于新标签

window.open('http://google.com','','height=500,width=500');
window.open().close();

不要使用popunders作恶

【讨论】:

    猜你喜欢
    • 2017-08-15
    • 2015-07-23
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 2014-03-24
    • 1970-01-01
    相关资源
    最近更新 更多