【发布时间】:2015-05-13 10:03:12
【问题描述】:
以下是我想要的示例,但目前有两个缺陷。
我认为订单不正确,因为我看不到 google.com 以外的任何 url 网站。代码中某些项目的位置必须有一些东西。我试过没有弹出窗口拦截器,但仍然无法显示其他窗口。
-
我相信这个程序应该在不同的窗口/标签中打开。我希望我在同一个窗口和选项卡中打开下一个 url 并替换原来的。
- 谷歌替换为msn; msn 换成了 yahoo
感谢您的帮助。谢谢大家。
代码:
<!DOCTYPE>
<html>
<body>
<script>
var urlList = ['http://www.google.com', 'http://www.msn.com', 'http://www.yahoo.com'];
var wnd;
var curIndex = 0; // a var to hold the current index of the current url
function openWindow(){
wnd = window.open(urlList[curIndex], '', '');
setTimeout(function () {
wnd.close(); //close current window
curIndex++; //increment the index
if(curIndex < urlList.length) openWindow(); //open the next window if the array isn't at the end
}, 2000);
}
openWindow();
</script>
</body>
</html>
【问题讨论】:
-
仅供参考。对于 html5 文档类型,您的文档类型应为
<!DOCTYPE html>。
标签: javascript html url