This method creates an HTML hypertext link that requests another URL.
The syntax for link() method is as follows −
string.link( hrefname )
hrefname − Any string that specifies the HREF of the A tag; it should be a valid URL.
Returns the string with <a> tag.
Try the following example.
<html> <head> <title>JavaScript String link() Method</title> </head> <body> <script type="text/javascript"> var str = new String("Hello world"); var URL = "http://www.tutorialspoint.com"; alert(str.link( URL )); </script> </body> </html>