![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a link from a text using JavaScript?
To create a link, use the JavaScript link() method. This method creates an HTML hypertext link that requests another URL. The following is the syntax:
string.link( hrefname )
Above, hrefname is any string that specifies the HREF of the <a> tag; it should be a valid URL.
Example
You can try to run the following code to learn how to work with link() method in JavaScript −
<html> <head> <title>JavaScript String link() Method</title> </head> <body> <script> var str = new String("Simply Easy Learning"); var URL = "http://www.tutorialspoint.com"; document.write(str.link( URL )); </script> </body> </html>
Advertisements