Saturday, January 28, 2012

link() Method in JavaScript

 
The link() method is used to display a string as a hyperlink.
This method returns the string embedded in the <a> tag,
like this: 

<a href="url">string here!!</a>

Syntax:

string.link(url);

JavaScript code:

<script language="javascript" type="text/javascript">
    function myUrl() {
        var myString = new String('Home Page');
        document.write(myString.link('http://anildroisys.blogspot.com/'));
    }
</script>

Html Code:
<button onclick="this.myurl();">Create a link from here! </button>

No comments: