I am creating a webpage in which I need to open a popup and it should remain open for 8 seconds (8000 ms).
After this period of time, the popup should be closed. Then again after 4 seconds I need to open the same popup for another 8 seconds.
I want to put some delay (4 seconds) so that the popup window opens and closes automatically, and the popup window should remain open for 8 seconds.
Here is my code:
<html> <head> <script> function call() { popup = window.open('http://www.google.co.in'); setInterval(function() {wait();},4000); } function caller() { setInterval(function() {call();},5000); } function wait() { popup.close(); } </script> </head> <body onload="caller();"> </body> </html>
I am familiar with java script functions like setInterval() and setTimeout() , but in this case I did not find anything useful. I also allowed the browser to open popups, but this script opens a popup and closes it over time. Please help me find out the failure in my code.
Thanks.
source share