Finding mouse position browser and screen size javascript


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 bodyvar 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 bodyvar 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);
}

Advertisements
This entry was posted in javascript and tagged by Purab Kharat. Bookmark the permalink.

About Purab Kharat

I am WordPress and Drupal Architect. I worked on many technologies like Ruby on Rails, Flex, PHP etc... I am Purab Kharat from India, Pune. I love to play chess and listen music and read books. I work in SY Smartsourcing Global Pvt Ltd in Princeton, NJ, USA. Now I am living at Plainsboro, 164 Hampshire Drive, Princeton Meadows, NJ. I have more then Ten years experience in Web Application Development (Specially in Php 5.0, Ruby on Rails, Mysql 5.0, RIA, Wordpress, Drupal, Joomla, Ecommerce)

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