How To Use String Object Link In JavaScript

In this article I am going to explain about String Object Link In JavaScript.
  • 1347

Use link() method in JavaScript

If we want to display a string in a hyperlink then we can use a link() method.

The <a> tag is used to return a string in JavaScript, like this:

<a href="url">string</a>.

All browsers support string object link() method.



<!DOCTYPE html>


<body Style="background-color:red">


<p id="demo">Click here</p>

<button onclick="myFunction()">Try it</button>

<script type="text/javascript">

    function myFunction()


        var txt = "Link:Hello World";

        document.getElementById("demo").innerHTML ="");









When we click on the string the website will be open which url link is given in

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.