Get the full URL of the current HTML document:
var x = document.URL;
Click the button to display the URL of the document.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w . j a v a2s .c o m var x = document.URL; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The URL property returns the full URL of the current HTML document.