InterviewHubPRO
Section Overview
Q127

Question 127 of 521

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

24%
JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

How do you get the current url with javascript

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
  console.log("location.href", window.location.href); // Returns full URL