JavaScript link()Method
JavaScript String Object
Definition and Usage
The link() method is used to display a string as a hyperlink.
This method returns the string wrapped in an <a> tag, as shown below:
<a href="url.html">string</a>
Syntax
string.link(url)
| Parameter | Description |
|---|---|
| url | Required. The URL to link to |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the link() method.
Examples
Example
Display the string "Free Web Building Tutorials!" as a link:
<script>
var str = "Free Web Building Tutorials!";
document.write(str.link("http://www.w3cschool.cc"));
</script>
var str = "Free Web Building Tutorials!";
document.write(str.link("http://www.w3cschool.cc"));
</script>
Try it Yourself »
JavaScript String Object Other Extensions