JavaScript String - link() Method
Advertisements
Description
This method creates an HTML hypertext link that requests another URL.
Syntax
The syntax for link() method is as follows −
string.link( hrefname )
Attribute Details
hrefname − Any string that specifies the HREF of the A tag; it should be a valid URL.
Return Value
Returns the string with <a> tag.
Example
Try the following example.
Live Demo<html> <head> <title>JavaScript String link() Method</title> </head> <body> <script type = "text/javascript"> var str = new String("Hello world"); var URL = "https://www.tutorialspoint.com"; alert(str.link( URL )); </script> </body> </html>
Output
<a href = "https://www.tutorialspoint.com">Hello world</a>
javascript_strings_object.htm
Advertisements