JS Coding Questions Logo
JS Coding Questions
#123💼 Interview💻 Code

How do you get the current url with javascript

Advertisement

728x90

You can use window.location.href expression to get the current url path and you can use the same expression for updating the URL too. You can also use document.URL for read-only purposes but this solution has issues in FF.

javascript
1console.log("location.href", window.location.href); // Returns full URL

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 39

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
123of476