I attach an Event in document.onkeyup and another event in
document.onbeforeunload
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.onbeforeunload =
functionObjRef;':
targetObject.onbeforeunload = null;
Or IE-only, if the event listener was assigned to the target object for the
event with targetObject.attachEvent("onbeforeunload", functionObjRef):
targetObject.detachEvent("onbeforeunload", 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