views:

176

answers:

1

The problem is as follows.

Onbeforeunload works like a charm in Firefox and has e.explicitOriginalTarget.activeElement that shows what element has been clicked to cause it.

window.onbeforeunload = function(e){ if (e.explicitOriginalTarget.activeElement){ return; }

In Chrome the 'e' object looks identical when you close the window or click the link. Is there any way to determine the target in chrome?

A: 

No. The target of the event is the window or document, not the link. Unlike Firefox, Chrome provides no helpful bonus properties on the event object. Your best bet may be to have an click event handler on the body that examines the event target to see if it's a link, but that's not foolproof: the link may have its own click event handler that prevents the default action, or the user may follow the link using the keyboard, in which case no click event will be fired.

Tim Down
just as i suspected. Thanks!
ZooKeeper