<html>
<body>
<p>This example demonstrates a solution that will work for all browsers.</p>
<p>Click anywhere in the document to alert some text.</p>
<script>
if (document.addEventListener) {
document.addEventListener("click", myFunction);
} else if (document.attachEvent) {
document.attachEvent("onclick", myFunction);
}
function myFunction() {
alert("Hello World!");
}
</script>
</body>
</html>