Handling onClick or Links : Hyper Link Event « Event « JavaScript DHTML






Handling onClick or Links

<HTML>
<HEAD>
<TITLE>Handling onClick for links</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function confirmLink() {
 alert("This is the Java2s Home Page.")
 return confirm("Are you sure you want to load this document?")
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<H1>Handling onClick for links</H1>
<P><A HREF="http://www.java2s.com" ONCLICK="return confirmLink()">
Asks you to confirm your selection of this link.</A></P>
</BODY>
</HTML>

           
       








Related examples in the same category

1.Using onMouseOver and onMouseOut Event Handlers
2.Handling onMouseOut or Links
3.Using Functions as Event Handlers
4.Using the Event Object with Navigator and Internet Explorer
5.Using the const Keyword
6.Using onClick and onDblClick Event Handlers