I am making a web page, in which I have to open a popup window and it should remain open for a time period of 8 seconds(8000 ms).
After this time period that popup should be closed. Then again after 4 seconds I need to open same popup window for another 8 seconds.
I want to put some delay(4 seconds) before a popup open and closes automatically, and the popup window must be remain opened 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 I've found none of them useful in this case.
I've also allowed my browser to open Popups, but this script opens a popup window and closes it as fast as time passes.
Please help me to find out the glitch in my code.
Thank you.