Anchor on click event
<html> <head> <title>A Simple Page</title> <script language="JavaScript"> function yourMessage() { alert("You clicked on a link!"); } </script> </head> <body> <a href="http://www.java2s.com" onClick="yourMessage()">My Website!</a> </body> </html>