How to find current URL in JavaScript

{0 Comments}

If you need to get url of the same page loading in JavaScript then document.URL will help you, this will return the only the current URL as implemented in following code snippets

 Javascript |  copy code |? 
1
var text=document.URL;
2
        document.write(text);
3

If above code is not helping you then you can use following code snippet. In which Window.location.href because I found some of the people have problem in popular browser like Firefox.  Among the two code sample one will defiantly help you.

 Javascript |  copy code |? 
1
var text=window.location.href;
2
        document.write(text);
3

Leave a Comment

Your email address will not be published.