Add event handler for mouse down event dynamically in JavaScript
Description
The following code shows how to add event handler for mouse down event dynamically.
Example
<html>
<head>
<title>X/Y Marks the Spot</title>
<script type="text/javascript">
function mouseDown(nsEvent) {<!--from w w w.java 2 s. c o m-->
var theEvent = nsEvent ? nsEvent : window.event;
var locString = "X = " + theEvent.screenX + " Y = " + theEvent.screenY;
document.writeln(locString);
}
document.onmousedown = mouseDown;
</script>
</head>
<body>
</body>
</html>