Global GuideLine Home HTML Tutorial JavaScript Tutorial SQL Tutorial CSS Tutorial SEO Tutorial XML Tutorial XSLT Tutorial Articles Tutorial Interview Questions and Answers Guide Jobs GuideLine Bookmark With Google Bookmark With Yahoo Bookmark With FaceBook Bookmark With Live Follow @GlobalGuideLine on Twitter Bookmark Global GuideLine
JavaScript on Hyperlinks, JavaScript Tutorial, Global Guide Line Technology.
Bookmark this webpage. Bookmark: JavaScript on Hyperlinks, JavaScript Tutorial Global Guideline is UNITED STATES's favorite website

      Home                    

Basic JavaScript Guide.
 JScript Introduction.            
 JScript Why?                       
 JScript Recognitions.          
 JScript onMouseover.         
 JScript with Buttons.           
 JScript Alerts.                     
 JScript Variables.               
 JScript Operators.               
 JScript Functions.               
 JScript Prompts.                 
 JScript Conditions.             
 JScript Validations.            
 JScript Confirmation Boxes.
 JScript Browser Detection.  
 JScript Redirection.            
 JScript on Links.
 JScript Switch.                    
 JScript Loops.                     
 JScript Events.                    
 JScript Exception Handling.
 JScript Reserve Characters. 
 JScript with Objects.            
 JScript Math Object.           
 JScript using Dates.             
 JScript using String.            
 JScript using Arrays.            
 JScript Operations.              
 JScript Handling Cookies.   
 JScript in Mapping.             
 JScript Time Out.                
 JScript Summary.                

Learn JavaScript with Examples
Learn JavaScript with hundred of short examples with code and output.
Complete_JScript_Examples.php

JScript Interview Questions & Answers
Learn JavaScript by thousands of Interview Questions & Answers.
JavaScriptQuestions/index.php

JavaScript Tutorial >> JavaScript on Hyperlinks.


     Back             Next     





As we know we can associate some JavaScript function with am HTML button or an image and we used JavaScript on buttons images, same way can be follow with hyperlinks.  The code to associate some JavaScript function on Hyperlink will be as under.

Syntax for JavaScript associated with Hyperlink

<a href="" onClick="someFunctionName()"> Any thing else </a>

In this example we can change the text and the URL of a hyperlink. We can also change the target attribute for the hyperlink. The target attribute is by default set to "_self", which means that the link will open in the same window. By setting the target attribute to "_blank", the hyperlink will open in a new window as shown in below code.

Example of JavaScript on Hyperlinks.

<html>
<head>
<script type="text/javascript">
function changeLink()
{
  document.getElementById('anchor').innerHTML="Explore Google Technologies"
  document.getElementById('anchor').href="http://www.google.com"
  document.getElementById('anchor').target="_blank"
}
</script>
</head>

<body>
  <a id="anchor" href="http://www.globalguideline.com">
     Explore JavaScript Tutorial at Global Guide Line Technologies.
  </a>
  <u><font color="#0000FF">
  <a href="javascript:changeLink()" target="_self">
     Change above Hyperlink, JavaScript is waiting for action
  </a>
  </font></u>
</body>

</html>

Out put for above JavaScript on Hyperlink code

Global Guide Line Technologies.       Click here to Change Link

     Back             Next     
 

JavaScript Anchor Object Examples



In order to link this page as Reference, click on below text area and pres (CTRL-C) to copy the code in clipboard or pres right click then copy the following lines after that past into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code:

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright © 2005-2006 www.globalguideline.com All rights reserved. Join Global Guide Line community. 470 visitors are online now