หากต้องการรับ URL ปัจจุบันด้วย JavaScript ให้ใช้ window.location href ทรัพย์สิน −
ตัวอย่าง
การสาธิตสด
<!DOCTYPE html>
<html>
<body>
<h3>Get current URL</h3>
<p id="test"></p>
<script>
document.getElementById("test").innerHTML = "URL of the page: " + window.location.href;
</script>
</body>
</html>