<!--Click 'button' to get the current URL--> <button onclick="myFunction()">button</button> <p id="result"></p> <script> function myFunction() { var x = location.href; document.getElementById("result").innerHTML = x; } </script>
<script> document.getElementById("demo").innerHTML = "The full URL of this page is:<br>" + window.location.href; </script>
window.location.href