【发布时间】:2013-10-02 07:10:34
【问题描述】:
从主线程调用的window.open() 默认打开新标签。
但是,这里每次都打开新窗口(Opera 16 和 Google Chrome 29)
<input type="button" value="Open" onclick="cb1()">
<script type="text/javascript">
function cb1() {
setTimeout(wo, 1000); //simple async
}
function wo()
{
var a = window.open("http://google.com", "w2");
a.focus();
}
</script>
(哈哈,这是我对Open a URL in a new tab (and not a new window) using JavaScript的回答)。
如何在标签页中打开(默认浏览器)?
【问题讨论】:
-
这种行为发生在什么浏览器中?
-
希望这是你的answer。
-
所有浏览器。测试页
-
@Gurminder Singh,所有浏览器配置都是正确的(默认选项卡,不阻止弹出窗口)。如果我直接调用 wo() ,一切都很好。
-
你试过了吗var a = window.open(url, '_blank');
标签: javascript asynchronous callback window.open