Get Mouse Position in Your Browser

I am building some new scroll event code and part of that code is making sure that new dynamic content loads based off the users position on the page.

I use chrome for just about all of my dev and a little bit of javascript in the console does wonders. Paste the following into your dev console and take the guesswork out of where your mouse position is

document.onmousemove = function(e){
var x = e.pageX;
var y = e.pageY;
e.target.title = "X is "+x+" and Y is "+y;
};

This code checks the x and y position in your browser every time you move your mouse and shows it on the screen. This was incredibly helpful for me when I was working on a dynamic and infinite loading scrollbar to be sure content was loading at the correct spot.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s