Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Javascript JavaScript method anchor()

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript method anchor()

Advertisement
This section illustrates you the use of JavaScript anchor() method. The anchor() method creates an HTML anchor with a NAME attribute on the specified text.

JavaScript method anchor()

     

This section illustrates you the use of JavaScript anchor() method. The anchor() method creates an HTML anchor with a NAME attribute on the specified text.

 

 

 

 

Its syntax is:

[string_object].anchor("anchor_name")

The anchor_name argument passed into the method anchor() is placed in the "NAME" attribute of the html anchor. In the given example, we have created a function display() and called the anchor() method on a String object. We have created a button which calls the function display() from the script and creates an html anchor by adding an anchor to the string specified . 

Here is the code:

<html>
<script>
function display(){
var txt="Hello world!";
alert((txt.anchor("myanchor"));
}
</script>
<h2>Use of anchor() method</h2>
<button onclick="display();">
Use of Anchor method
</button>
</html>

Output will be displayed as:

On clicking the button, you will see that the HTML anchor is created. This is shown in the alert box.

Download Source Code:

 

     

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 3, 2006

Related Tutorials

Discuss: JavaScript method anchor()  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com