Click to See Complete Forum and Search --> : self closing a window
hanhao
06-04-2006, 07:06 AM
ok i need to self close a window (like after 5 seconds)
anyone knows the command to close the window?
would
echo "self.close()"; ?
be correct?
- hanhao
Weedpacket
06-04-2006, 07:37 AM
PHP can't do this because it doesn't know what a "window" is.
Javascript could do it, though. Something like
<script type="text/javascript">self.close();</script>Though you'll probably need to search the net a bit to see how Javascript does timers (I can never remember, so that's what I end up doing every time I need to do it. SetTimeout() or something like that.)
bradgrafelman
06-08-2006, 09:46 PM
Yeah... I have trouble with it too, so here's my guess: <script type="text/javascript"> setTimeout("self.close()", 5000); </script>
JPnyc
06-08-2006, 11:23 PM
That is the correct syntax, but be aware that you can only close a window with scripting, that you opened. You can't close the initial window used to navigate to your site. IE will throw up a prompt asking if the user wants to allow, and the other major browsers just ignore it.
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.