Finding mouse position browser and screen size javascript

This article will be use for Finding mouse position browser with only javascript. Javascript is base for many framework. If you have strong knowledge of javascript then you will be able to write any code in web sites.

Following script Will tested and working on following browsers.
1. Firefox 2+
2. Google chrome
3. Safari
4. IE 6, 7, 8
5. Opera
You can Use following code for Capturing the Mouse coordinates as per Document body

var isIE = document.all?true:false;
// document.onmousemove = getMousePosition;
// document.onmousemove = getscreenPosition;
function getMousePositionBrowsersizeWise(e) { // as per Document body
var _x;
var _y;
if (!isIE) {
_x = e.pageX;
_y = e.pageY;
}
if (isIE) {
_x = event.clientX + document.body.scrollLeft;
_y = event.clientY + document.body.scrollTop;
}
alert(_x);
alert(_y);
}

You can Use following code for Capturing the Mouse coordinates as per Screen Resolution

function getMousePositionScreenWise() {
var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;
var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;
alert(ScrY);
alert(ScrX);
}

Following script Will tested and working on following browsers.1. Firefox 2+2. Google chrome 3. Safari4. IE 6, 7, 85. Opera
You can Use following code for Capturing the Mouse coordinates as per Document body

var isIE = document.all?true:false;// document.onmousemove = getMousePosition;// document.onmousemove = getscreenPosition; function getMousePositionBrowsersizeWise(e) { // as per Document body var _x; var _y; if (!isIE) { _x = e.pageX; _y = e.pageY; } if (isIE) { _x = event.clientX + document.body.scrollLeft; _y = event.clientY + document.body.scrollTop; } alert(_x);alert(_y); }

You can Use following code for Capturing the Mouse coordinates as per Screen Resolution

function getMousePositionScreenWise() {var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;
alert(ScrY);alert(ScrX);
}

Following script Will tested and working on following browsers.1. Firefox 2+2. Google chrome3. Safari4. IE 6, 7, 85. Opera
You can Use following code for Capturing the Mouse coordinates as per Document body

var isIE = document.all?true:false;// document.onmousemove = getMousePosition;// document.onmousemove = getscreenPosition;function getMousePositionBrowsersizeWise(e) { // as per Document bodyvar _x;var _y;if (!isIE) {_x = e.pageX;_y = e.pageY;}if (isIE) {_x = event.clientX + document.body.scrollLeft;_y = event.clientY + document.body.scrollTop;}alert(_x);alert(_y);}

You can Use following code for Capturing the Mouse coordinates as per Screen Resolution

function getMousePositionScreenWise() {var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;alert(ScrY);alert(ScrX);}

Following script Will tested and working on following browsers.1. Firefox 2+2. Google chrome 3. Safari4. IE 6, 7, 85. Opera
You can Use following code for Capturing the Mouse coordinates as per Document body

var isIE = document.all?true:false;// document.onmousemove = getMousePosition;// document.onmousemove = getscreenPosition;
function getMousePositionBrowsersizeWise(e) { // as per Document body  var _x;  var _y;  if (!isIE) {    _x = e.pageX;    _y = e.pageY;  }  if (isIE) {    _x = event.clientX + document.body.scrollLeft;    _y = event.clientY + document.body.scrollTop;  }
alert(_x);alert(_y);  }

You can Use following code for Capturing the Mouse coordinates as per Screen Resolution

function getMousePositionScreenWise() {var ScrX = window.screenLeft != undefined ? window.screenLeft : window.screenX;var ScrY = window.screenTop != undefined ? window.screenTop : window.screenY;
alert(ScrY);alert(ScrX);
}

Viman Nagar Rd, Viman Nagar, पुणे, Maharashtra, India

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.