gpt4 book ai didi

javascript - 如何在 Opera/Google Chrome 浏览器中打开两个选项卡窗口?

转载 作者:行者123 更新时间:2023-11-28 01:10:00 25 4
gpt4 key购买 nike

<a href="#" onclick="return openTwoWindowTab();">Click Here</a>

<script>
function openTwoWindowTab(){
window.open('www.google.com','_blank');
window.open('www.yahoo.com','_blank');
}
</script>

在这里,我尝试在单击链接时打开两个窗口选项卡。

1) 在 Mozilla Firefox 18.0.2 中运行良好

2) 但在 google chrome 中只打开一个选项卡。版本35.0.1916.114

3) 在 Opera 中也仅打开一个选项卡。最新版本

这对我来说是非常关键的问题......任何帮助/建议......

最佳答案

我的建议是这样做:

function openTwoWindowTab() {
// create object to serve the urls
var obj = {
0: 'http://www.google.com',
1: 'http://www.yahoo.com'
};
setTimeout(function () { // use setTimeout function to wait for other window to open
// otherwise one window will be opened in the browser window
for (var a = 0; a <= Object.keys(obj).length - 1; a++) {
window.open(obj[a], '_blank');
}
}, 1000);
}

Demo

关于javascript - 如何在 Opera/Google Chrome 浏览器中打开两个选项卡窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24568922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com