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?

7 of 16 people (44%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

which event should i capture when the browser closes using the x button.

Apr 6th, 2008 19:20
ha mo, Colin Fraser, Rohit Gupta,


Capturing events, in a general sense (but I am going to make one of
those statements that is partly right, but also partly wrong), occurs at
the level of the document. You cannot capture events that occur at the
browser level, so capturing the "x button", as you put it, is not going
to happen. Javascript is just not that powerful, yet. 
However, what you are asking is possible, just by doing it another way.
Try (in the <head> ):
<script> <!--//hide
  function doThis() {
      alert("Goodbye!");
  }
</script>
Then with the <body> tag try : 
<body onUnload="doThis()">   
This should do what you want it to.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com