Return to Snippet

Revision: 33762
at October 13, 2010 03:29 by delikassap


Initial Code
function FindPosition(e) {
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
}

Initial URL
http://www.quirksmode.org/js/events_properties.html

Initial Description

                                

Initial Title
Crossbrowser Mouse Click Position

Initial Tags

                                

Initial Language
JavaScript