The window.location object can be used to get the current URL.
window.location.href returns the href(URL) of the current page.
I am using these code in my MVC projet.
Example
<html> <body> <div> <p id ="dd"></p> </div> <script type="text/javascript"> var iid=document.getElementById("dd"); alert(window.location.href); iid.innerHTML = "URL is" + window.location.href; </script> </body> </html>