Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 22nd, 2004, 10:47 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Default Browser onClose event??

Hi all,
How can I handle the closing event of the browser window?
In other words, if there's no event in javascript for browser window closing, then what do you do when you want to call a server page and pass some info to it, just before the client's page is closed?
(onBlur,onunload,and some other events wouldn't work here or the do the job but woudn't do it exclusively.I mean they might happen on some other ocasions too)


 
Old November 22nd, 2004, 11:16 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You have to make do with onunload or in some browsers onbeforeunload.



--

Joe (Microsoft MVP - XML)
 
Old November 23rd, 2004, 02:21 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As I mentioned before Unload event ain't just for browser closing. It's also trigers when your refresh or traverse through url links and some other situations...

 
Old November 23rd, 2004, 05:36 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I missed what you were asking, yes it happens however you leave the page. You can't tell directly. Depending on your set up you could keep send the data in the onunload and then server side you check in the session_end event if anything needs saving. It's a difficult scenario given the stateless nature of HTTP and how browser based app work.



--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Event - Sender & Event args dash dev C# 2005 9 December 9th, 2007 07:24 AM
Refresh parent onclose of child mat41 Javascript 7 October 23rd, 2007 01:43 AM
Browser back button makes wrong event fire Surre ASP.NET 1.0 and 1.1 Professional 1 March 13th, 2006 03:40 PM
Launch default browser in a new browser window haiying Beginning VB 6 1 August 30th, 2005 05:48 PM
About Button event and Keydown event zhangxujun1981 XSLT 1 March 6th, 2004 04:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.