Mega Code Archive

 
Categories / JavaScript DHTML / HTML
 

Validate Link

<html> <head> <script language="JavaScript"> <!-- function validateLink(theLink) {  if (parseInt(theLink) > document.anchors.length)     alert("Sorry, this anchor has not been defined");  else     location.hash = theLink; } //--> </script> </head> <body> <form> <input type="button" value="Chapter 1" onClick="validateLink('0')"> <input type="button" value="Chapter 2" onClick="validateLink('1')"> </form> <a name="0">CHAPTER 1</a> <p>  Put some more text in here ...</p> <a name="1">CHAPTER 2</a> <p>  Put some more text in here ...</p> </body> </html>