PDA

View Full Version : auto close



gavinv3
10-27-2007, 01:53 PM
Hi Guys,
Is it possible to code an Html page to auto close after 5 seconds after it loads up?

Regards,
Gav

boogyman
10-27-2007, 02:03 PM
I cannot see any viable use for this except as a popup script, but


<body onload="javascript:setTimeout(window.self.close(), 5*1000);">

where 5 is the number of seconds you wish to close the page

jscheuer1
10-27-2007, 02:20 PM
Many browsers will not allow that.

gavinv3
10-27-2007, 02:26 PM
That was great - Thanks a lot - except for that popup asking for confirmation to close - can that be avoided by any chance so the window closes on its own without notice

BLiZZaRD
10-27-2007, 02:42 PM
Many browsers will not allow that.

err... what he said... :)

jscheuer1
10-27-2007, 03:14 PM
You can spoof some browsers into thinking that the window was opened by javascript, but not all. Those that can be fooled will stop popping the confirmation question (note - some won't ask to begin with, just won't close the window). You could (if your set up lends itself to this strategy) actually open the window with javascript to begin with. Then, virtually any browser that will allow it to open in the first place, will allow it to close. However, many browsers will block it as a pop up, or if they have javascript disabled, not open it to begin with. In some tabbed browsers, a situation could arise where the entire browser closes, or attempts to close.

Generally it's not nice to mess with windows, stick to the documents.

tech_support
10-28-2007, 01:38 AM
<script type="text/javascript">
function fullClose() {
window.opener=self;
window.close();
}
window.onload=function() {
setTimeout(fullClose,5000);
}
</script>

jscheuer1
10-28-2007, 05:10 AM
<script type="text/javascript">
function fullClose() {
window.opener=self;
window.close();
}
window.onload=function() {
setTimeout(fullClose,5000);
}
</script>


Not in FF. Perhaps not in some others. Other of the issues I mentioned would still apply, even if the above worked in all browsers, which it doesn't.

gavinv3
10-28-2007, 02:15 PM
Marvelous
You guys got the brains - I really appreciate your help- that's exactly what I was looking for - Thank you John and Tech Support - I love you guys for the time every one in this forum puts in to help us

- Not to forget Blizz thanks for being there all the time mate, you are my guardian angel I should say

*********** Tech Support, Please check why my photo is not showing up besides my name - I had uploaded it yesterday **********