JavaScript
Code Placed in BODY:
<html> <head> </head>
<body> <script> alert("This alert box appeared automatically when the page loaded because the script is placed in the BODY") </script> </body> </html>
Result:
The alert box loaded automatically when this page was loaded. You did not have to trigger the event.
Code Placed in HEAD:
<html> <head> <script> function message() {alert("This alert box was called with the onclick event")} </script> </head>
<body> <input type="button" value="click" onClick="message()"> </body> </html>