【发布时间】: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 键,但没有达到我想要的效果:新页面刚刚打开并获得焦点。
我能做到吗?
注意强调浏览器和版本。
【问题讨论】:
-
@Kos 这些答案在 Chrome 62 上不起作用。
标签: javascript google-chrome window-object