Call a function in javascript on all onclick events
I want to call a function in javascript. I want to call this function on click of every events or at least on click of all the onclick events in the doc开发者_运维知识库ument.
Please let me know how to do this.
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!--
document.onclick = myClickHandler;
function myClickHandler() {
alert("The document was clicked!");
}
-->
</script>
</head>
<body>
click anywhere within this document.
<a href="x.html">this will fire the handler too!</a>
</body>
</html>
精彩评论