JavaScript on Hyperlinks, JavaScript Tutorial, Global Guide Line Technology.
Forum | Blog |


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.                

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.

<script type="text/javascript">
function changeLink()
  document.getElementById('anchor').innerHTML="Explore Google Technologies"

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


Out put for above JavaScript on Hyperlink code

Global Guide Line Technologies.       Click here to Change Link

     Back             Next     

JavaScript Anchor Object Examples

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

Copyright 2005 -  2023 All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 416 visitors are online now