View Full Version : Capturing Browser Events
Scott
04-15-2004, 11:12 AM
When a user leaves a particular page, I need to be sure that a post back is generated in order to capture any changes the user made and save them to a database. This is easy enough to accomplish if the user uses the site's menu to navigate to a new page.
The problem is in grabbing the changes if the user navigates to another page via the browser forward or back functions or by typing a new address in the address bar. Any ideas on how to trap these browser events programatically and save the changes before the user navigates away?
bruce
04-15-2004, 12:11 PM
i think the only way to do that is to use Javascript that track the event.
quote:Originally posted by Scott
When a user leaves a particular page, I need to be sure that a post back is generated in order to capture any changes the user made and save them to a database. This is easy enough to accomplish if the user uses the site's menu to navigate to a new page.
The problem is in grabbing the changes if the user navigates to another page via the browser forward or back functions or by typing a new address in the address bar. [b]Any ideas on how to trap these browser events programatically and save the changes before the user navigates away?
</blockquote id="quote"></font id="quote">
hridpath
04-18-2004, 08:07 AM
Have you tried to wireup the page_unload event on the body.
quote:Originally posted by Scott
When a user leaves a particular page, I need to be sure that a post back is generated in order to capture any changes the user made and save them to a database. This is easy enough to accomplish if the user uses the site's menu to navigate to a new page.
The problem is in grabbing the changes if the user navigates to another page via the browser forward or back functions or by typing a new address in the address bar. [b]Any ideas on how to trap these browser events programatically and save the changes before the user navigates away?
</blockquote id="quote"></font id="quote">
Scott
04-19-2004, 11:11 AM
hridpath-
Thanks for the suggestion. However, page_unload is a server-side, not a client-side event. That is, it fires just after the server renders the html for the page, but before the page is sent to the client. Unload does not fire when the page is unloaded by the client browser.
Bruce's post suggested javascript and it maybe that either window.onBlur or window.unload can provide the functionality I'm looking for.
[quote]Originally posted by hridpath
Have you tried to wireup the page_unload event on the body.
[/quote\
vBulletin® ©Jelsoft Enterprises Ltd.