so*********@gma il.com wrote:
I attach an Event in document.onkeyu p and another event in
document.onbefo reunload
in onkeyup event, if the condition is satisfied, i will activate sth,
then i don't want the onbeforeunload event to happen.
is it possible to accomplish this?
That would depend on what you call "attach an Event". It is possible to
prevent the _event listener_ from being called (that is not preventing the
event from happening), by assigning `null' to the event handler property
if the event listener was assigned with `targetObject.o nbeforeunload =
functionObjRef; ':
targetObject.on beforeunload = null;
Or IE-only, if the event listener was assigned to the target object for the
event with targetObject.at tachEvent("onbe foreunload", functionObjRef) :
targetObject.de tachEvent("onbe foreunload", functionObjRef) ;
(There is no mention of a standards compliant `beforeunload' event yet,
so the methods of W3C DOM Level 2 Event should not apply, and it is
error-prone to use them here.)
Another approach is to set a flag to prevent pieces of code in the event
listener from being executed, but the event listener will be called anyway.
PointedEars