Skip to content

Instantly share code, notes, and snippets.

@Trshant
Created June 2, 2015 05:52
Show Gist options
  • Save Trshant/f4221c5563647f5f2b7f to your computer and use it in GitHub Desktop.
Save Trshant/f4221c5563647f5f2b7f to your computer and use it in GitHub Desktop.
This will get the mouse position in javascript.
var position = {};
document.addEventListener('mousemove', function(e){
position = { x: e.clientX, y: e.clientY } // for browser window WRT
position = { x: e.pageX, y: e.pageY } // for page WRT
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment