Are you first timer at Why not join us and start exchange your knowledge with everyone. Register today!

JS - get current URL

0 votes
added Jun 12 in Javascript by birdygeek Sergeant (2,060 points)
<!--Click 'button' to get the current URL-->
<button onclick="myFunction()">button</button>

<p id="result"></p>

function myFunction() {
    var x = location.href;
    document.getElementById("result").innerHTML = x;

1 Response

0 votes
responded Jun 12 by Callum Sergeant (1,430 points)
document.getElementById("demo").innerHTML = 
"The full URL of this page is:<br>" + window.location.href;
</script> - Malaysia based Knowledge Exchange Platform, where you can share your finding or solution with other members of community.