View Full Version : window.close()
Jason
03-11-2003, 10:35 PM
I want to be able to close a window in 5 or so seconds after a button is clicked. Now I can close it immediately with window.close() but is there a way to keep it open for a bit longer? so that the server can finnish executing the code?
Jason
liorean
03-11-2003, 10:45 PM
Well, what you want is set Timeout(). for details, see <http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1203758>
Jason
03-11-2003, 10:55 PM
ok that helps, but I think I need some syntax help since I can't get it to properly work.
document.writeln ( '<INPUT TYPE="submit" Value="Update" ONCLICK="setTimeout("window.close()",25 )">' );
that is my call, but the quotes are getting excessive, now how can I give a quote within a quote?
Jason
beetle
03-11-2003, 10:58 PM
Escape them!
document.writeln ( '<INPUT TYPE="submit" Value="Update" ONCLICK="setTimeout(\'window.close()\',25 )">' );
Jason
03-11-2003, 11:01 PM
now where am I going wrong? that call doesn't work anymore. The timeout doesn't do anything and my form no longer submits.
Jason
liorean
03-11-2003, 11:02 PM
Originally posted by Jason
document.writeln ( '<INPUT TYPE="submit" Value="Update" ONCLICK="setTimeout("window.close()",25 )">' );
that is my call, but the quotes are getting excessive, now how can I give a quote within a quote?
Jason [/B]
Try this:
document.writeln ( '<input type="submit" value="Update" onclick="setTimeout(\\'window.close()\\',25 )">' );
In javascript, a string can contain the quoting character by escaping it with a backslash. e.g: 'don\\'t forget this' or "on the sign, you could read out the words \"ye olde\"."
In HTML, you can use &0043; for " and &0039; for '.
Jason
03-11-2003, 11:06 PM
thanks all, I figured it out with your help that is. I was using the wrong quotes in the wrong area.
Jason
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.