Access window event in JavaScript

Description

The following code shows how to access window event.

Example


<html>
<head>
<!--   w  ww.j a  v a 2 s .c o m-->
<script type="text/javascript">
function mouseDown() {
var locString = "X = " + window.event.screenX + " Y = " + window.event.screenY;
document.write(locString);
}

document.onmousedown=mouseDown;
</script>

</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Access window event in JavaScript
Home »
  Javascript Tutorial »
    Event »
      Browser Event
Javascript Tutorial Browser Event
Access window event in JavaScript
Add event handler for body onload event in ...
Add event handler for window on load event ...
Add onload event handler by using attribute...
Cancel event with preventDefault in JavaScr...
Filter click event to capture in JavaScript
Filter event to catch in JavaScript
Handle Error event on body in JavaScript
Handle browser window resize event in JavaS...
Handle document on changed event in JavaScr...
Handler document on abort event in JavaScri...