The web is a dynamic environment where a lot of things happen. Most appropriately, they’re called events. Some of these events, like a user clicking a button or moving the mouse over a link, are of great interest to a JavaScript coder.
- onClick event: triggered by you as you click the link;
- onUnload event: triggered by the web browser as it leaves the current web page;
- onLoad event: triggered by the browser as the new web page content is loaded.
Example specified below
<a href="http://html.net" onclick="alert('Going anywhere? Not so fast!'); return false;">Click Me!</a>