faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 16 people (56%) answered Yes
Recently 4 of 10 people (40%) answered Yes


how can i close a child window without events, after the page finish displaying all it contents

Apr 6th, 2008 18:35
ha mo, Colin Fraser, alex odeh,

The question really is how long do you want your popup to display before
you close it?  You could always do something like 
<body onload="self.close()">
which triggers immediately after the document has finished loading, or
it is supposed to. However, this is always risky, even if the syntax is
right. You may however want a delay :
<SCRIPT LANGUAGE="JavaScript"><!--
function winClose() { 
....page text here....
<SCRIPT LANGUAGE="JavaScript"><!--
//and at the end of the page place this call
You may feel that 10 seconds is too long, so make it 5000 to display for
  only 5 seconds. However, you could also use the onLoad event to make
sure that all images and text and anything else is downloaded. In that
case, the body tag reads 
  <body onLoad="winClose()"> 
I would not recommend you do anything fancy, but you could set the time
out according to some whim, say ask for a name then calculate the total
value of the letters and assign that to a variable which then uses the
number as the time out value. You could also do lots of ther things but
they would generally be time wasting... good luck..