DOM:event.screenX
From MDC
Contents |
[edit] Summary
Returns the horizontal coordinate of the event within the screen as a whole.
[edit] Syntax
pixelNumber = event.screenX
pixelNumberis the offset from the left side of the screen in pixels.
[edit] Example
<html>
<head>
<title>screenX\screenY example</title>
<script type="text/javascript">
function showCoords(evt){
alert(
"screenX value: " + evt.screenX + "\n"
+ "screenY value: " + evt.screenY + "\n"
);
}
</script>
</head>
<body onmousedown="showCoords(event)">
<p>To display the mouse coordinates click anywhere on the page.</p>
</body>
</html>
function checkClickMap(e) {
if (e.screenX < 50) doRedButton();
if (50 <= e.screenX) < 100 doYellowButton();
if (e.screenX >= 100) doRedButton();
}
[edit] Notes
When you trap events on the window, document, or other roomy elements, you can get the coordinates of that event (e.g., a click) and route it properly, as the "clickMap" example demonstrates.