how to display alert when mouse cursor goes out of window

284
November 21, 2016, at 9:36 PM

I want to display alert when the mouse goes out of window . Like http://ezwebsitebiz.com/testing-content/

i want to do this in jquery . how it can be achived

Answer 1
var currentMousePos = { x: -1, y: -1 };
        jQuery(document).mousemove(function(event) {
            currentMousePos.x = event.pageX;
            currentMousePos.y = event.pageY;
        });

jQuery(document).mouseleave(function() {
            var window_width = jQuery(window).width();
            var window_height = jQuery(window).height();

            if((currentMousePos.x < window_width) && (currentMousePos.y > 50))
                return true;
           alert(currentMousePos.x.toString());

        })

Replace alert message with your popup window or fancy box

READ ALSO
How to get a piece of an json object with its parent node?

How to get a piece of an json object with its parent node?

How can I just get a part of my object including its parent node?.

271
Any number starting with a 0 is recognized as a phone number?

Any number starting with a 0 is recognized as a phone number?

During testing we noticed that on mobile devices, any number that is displayed starting with a 0 is recognized as a phone number. How can I keep this from happening?.

227
Set CSS table height to x number of rows heights combined

Set CSS table height to x number of rows heights combined

I am doing a 'quick' css fix for one of our OCD product owners, I have table that is 500px in height, it displays anything from no rows to thousands, the overflow is set to scroll so you can scroll down the list of items. .

298