From the MDN beforeunload event, you can see which properties are supported from the event object.
Client X and clientY of the event object are not supported, therefore they are undefined.
This also happens in Chrome and FF, since the onbeforeunload event does not contain such information (positional X and Y)
I checked your code in IE11, Chrome 48, FF 44.
Possible workaround:
var clientX = 0; var clientY = 0; var scheduled = false; window.onmousemove = function (event) { if (!scheduled) { scheduled = true; setTimeout(function () { event = event || window.event; clientX = event.clientX; clientY = event.clientY; scheduled = false; }, 1000); } } window.onbeforeunload = function (event) { alert(clientY+":"+clientX); if (clientX < 0 || clientY < 0) {
gaetanoM
source share