Tags: asp, call, event, fired, function, haschanged, javascript, leaves, net, onbeforeunload, page, script, toa, twice, user, working

onbeforeunload event is fired twice

On .Net » .Net Asp

811 words with 0 Comments; publish: Thu, 27 Dec 2007 11:52:00 GMT; (10062.50, « »)

I have been working on a script to check if a page has

changed before the user leaves the page. I have a call to

a javascript function on the onbeforeunload event.

This seems to work in most cases. However, in my

testing, the onbeforeunload event is sent twice. This

causes problems in certain cases where I want to suppress

the "The page has changed" message, as in the case

of a "Cancel" button being hit.

This is a similar problem to the one discussed

10/17/2003 in:

"need JavaScript to prevent people from closing a browser


I am using C# with ASP.Net version 1.1, and my HTML is

within a frameset.

Any help would be greatly appreciated. If there is a

workaround to "eat" the second event, that might work.


All Comments

Leave a comment...