How to get the current URL using javascript?

The way to get the current URL using java script is as follows:

var thisUrl = window.location.href;
alert( thisUrl );

The output will be :

 http://www.example.com/page.php?name=value

Leave a Reply