

Coordinate Properties See Also: The Mouse Event Object Syntax event.
Javascript mousex free#
Replace the x-position and y-position hard-coded values with the x-position and y-position of the mouse’s position using the mouseX and mouseY variables, respectively. W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Definition and Usage The pageX property returns the document relative X coordinate of the mouse pointer when a mouse event occurs.

Note that the value of the clientX property includes the width of the left border of the client area in Internet Explorer. Line 125 var rGradient context.createRadialGradient(mouseX, mouseY, 10, mouseX, mouseY, 45) Create the radial gradient as the fill color for the sun. See the Example 2 below, it provides a cross-browser solution for the use of the clientX property.
• From Internet Explorer 8 and in Firefox, Opera, Google Chrome and Safari, the position is calculated in the current pixel size.įor example, if the zoom level is 200%, the clientX property retrieves two times greater values before version 8 than from version 8 for the same mouse position.