ChathinduSL ChathinduSL - 3 years ago 124
HTML Question

Add current browser URL into HTML hyperlink

I am new to "Stack OverFlow".. I am making a chrome extension.
I want to add current url into html link..

See this...

<a href="**Current URL**">Search</a>

add your answer code into my code and give me full code please!!! i am new guy to html(js,css)

Can you help me please????

Thank You!

Answer Source

[The snippet will throw an error, but window.location is what you are looking for]

Set an ID to your anchor tag. then do this:

var link = document.getElementById("demo");
link.href = "" + window.locatoin;
<a id="demo" href="**Current URL**">Search</a>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download