Javascript examples for DOM Event:onclick
Assign the "onclick" event to the window object:
<!DOCTYPE html> <html> <body> <p>Click anywhere in this window to change the background color of body.</p> <script> window.onclick = myFunction;/* w w w.j a va 2s. c om*/ function myFunction() { document.getElementsByTagName("BODY")[0].style.backgroundColor = "yellow"; } </script> </body> </html>