in other words, which is the javascript/jquery code used to detect the event
when the mouse pointer is over the close button (X-button) of the browser,
or when the mouse pointer is enter the X-button of the browser.
obs: something like (http://www.jpost.com), enter the site and put the
mouse pointer in the close button(X-button) of the browser.
That is called exit intent.
You cannot track user mouse movement outside document.
But you can check on mouse out what was the movement vector and predict if it was intent to close or something else
Simplified version of tracking exit intent
https://jsfiddle.net/kristapsv/qs3wk8Ld/
var addEvent = function(obj, evt, fn) {
if (obj.addEventListener) {
obj.addEventListener(evt, fn, false);
}
else if (obj.attachEvent) {
obj.attachEvent("on" + evt, fn);
}
};
addEvent(document, "mouseout", function(event) {
event = event ? event : window.event;
var from = event.relatedTarget || event.toElement;
if ( (!from || from.nodeName == "HTML") && event.clientY <= 100 ) {
alert("left top bar");
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With