Answers for "how to access url in javascript"

5

jquery get current url

var currentURL = $(location).attr('href'); //jQuery solution
var currentURL = window.location.href; // raw javascript
Posted by: Guest on July-23-2019
7

javascript get url path

window.location.pathname
Posted by: Guest on June-06-2020
0

javascript url

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<h3>The window.location object</h3>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 
"The full URL of this page is:<br>" + window.location.href;
</script>

</body>
</html>
Posted by: Guest on March-04-2021

Code answers related to "how to access url in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language