View Full Version : Closing page
etg4free
11-11-2007, 09:16 PM
I need a page to automatically close after a set interval of time. Any ideas?
BarrMan
11-11-2007, 09:29 PM
I need a page to automatically close after a set interval of time. Any ideas?
You can't totally close the page without the user to have access on it but you can do it with JavaScript and the browser will ask the user if he wants to close the web page.
function closePage(time)
{
window.setTimout("closeIt()",time);
}
function closeIt()
{
window.close();
}
Then to initiate the function you just use the body onload attribute or window.onload method on the closePage function.
etg4free
11-11-2007, 11:16 PM
It's very important that the user isn't asked if he would like to close it.
jlhaslip
11-11-2007, 11:23 PM
Where do you want the Browser to go to after the page closes? You could use a meta tag to do something for you.
<meta http-equiv="refresh" content="2;url=http://jlhaslip.com/somefile.html">The number is the time, in seconds, until the page should be redirected. Then, separated by a semi-colon ( ";" )is the URL that should be loaded.
etg4free
11-12-2007, 12:13 AM
here it is for anyone else that needs it
<Script language=""javaScript"">
window.opener=self;
window.close();
window.open('test.htm','Test','fullscreen');
</script>
jlhaslip
11-12-2007, 03:28 AM
What does that do which isn't done with a meta refresh?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.