JavaScript link()Method

String 对象参考手册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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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>

Try it Yourself »


String 对象参考手册JavaScript String Object Other Extensions