Validate Link : JavaScript DHTML examples (example source code) » HTML » Hyper Link

JavaScript DHTML
C++
Java Products
Java Articles
JavaScript DHTML Home  »   HTML   » [  Hyper Link  ]   
 



Validate Link

Please note that some example is only working under IE or Firefox.

/*
Javascript Essentials
by Jason J. Manger

Publisher: Mcgraw-Hill Osborne Media; 

ISBN: 0078822343
*/

<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>
<!-- 
  Put some more text in here ...
-->

<a name="1">CHAPTER 2</a>
<!-- 
  Put some more text in here...
-->

</body>
</html>
Related examples in the same category
1.  Inserts a link on a text, a picture, a button or a dynamic picture
2.  Mouse over an hyper link
3.  Get link infomation in a paragraph
4.  Output link
5.  Illustrate how a URL can be referenced
6.  Call function in hyper link
7.  Change Link Colors
8.  Passing Form Value In URL
9.  Using JavaScript linkTo Entities
10.  Prevent the browser from following the link
11.  Redirect user depending on browser
12.  Location: Send the client to a new location (URL/page)
13.  URL of a document
14.  Change URL and text of a hyperlink
15.  Change the target attribute of a link
16.  Link focus() and blur()
17.  View and change the action URL of a form
18.  List the links in a page








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.