admin管理员组文章数量:1297131
I am looking for javascript code which will open new tabs(windows) automatically after specific interval of time.
i have few websites over here, in this code which open automatically when i press the button on the html page.
I want these websites to open after specific interval. like, 1st website will open when user will press button "Open Windows", 2 nd website after 1 minute and 3 rd websites after 2 minutes.
eg.
<html>
<head>
<script type="text/javascript">
function open_win() {
window.open("")
window.open("")
window.open("")
}
</script>
</head>
<body>
<form>
<input type=button value="Open Windows" onclick="open_win()">
</form>
</body>
</html>
Thank you,
sangram
I am looking for javascript code which will open new tabs(windows) automatically after specific interval of time.
i have few websites over here, in this code which open automatically when i press the button on the html page.
I want these websites to open after specific interval. like, 1st website will open when user will press button "Open Windows", 2 nd website after 1 minute and 3 rd websites after 2 minutes.
eg.
<html>
<head>
<script type="text/javascript">
function open_win() {
window.open("http://www.google.")
window.open("http://www.yahoo.")
window.open("http://www.bing.")
}
</script>
</head>
<body>
<form>
<input type=button value="Open Windows" onclick="open_win()">
</form>
</body>
</html>
Thank you,
sangram
Share asked Feb 14, 2011 at 6:48 Sangram NandkhileSangram Nandkhile 18.2k19 gold badges84 silver badges116 bronze badges2 Answers
Reset to default 5In most modern browsers you are not allowed to call window.open
programatically, like through a setTimeout
.
The browser will simply ignore the window.open
statement if it is not inside a callstack that is initiated by a direct user interaction, for instance a mouse click event.
The reason for this is that it is very annoying behavior - you probably won't find a single person who enjoys using a site that opens windows by itself.
So: reconsider what you are trying to do, there is bound to be a better way - one where you can work with the browser/user and not against it/him/her :)
function open_win() {
window.open("x.");
setTimeout("window.open('y.')",60000);
setTimeout("window.open('z.')",120000);
}
This should open x. then after one minute y. and after two it should open z..
本文标签: javascriptopening new windows after specifc interval of time using windowopen()Stack Overflow
版权声明:本文标题:javascript - opening new windows after specifc interval of time using window.open() - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741647332a2390263.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论