Communities for your favorite technologies. Explore all Collectives
Now available on Stack Overflow for Teams! AI features where you work: search, IDE, and chat.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Get early access and see previews of new features.
When would you set location to a URL string versus setting location.href?
location
location.href
location = "http://www.stackoverflow.com";
vs
location.href = "http://www.stackoverflow.com";
Mozilla Developer Network Reference
Reference: https://developer.mozilla.org/en-US/docs/Web/API/window.locationMozilla Developer Network Reference
When would you set location to a URL string versus setting location?
Reference: https://developer.mozilla.org/en-US/docs/Web/API/window.location
When would you set window.locationlocation to a URL string versus setting window.location.hreflocation?
window.location = "http://www.stackoverflow.com";
window.location.href = "http://www.stackoverflow.com"com";
Reference: https://developer.mozilla.org/En/DOM/Window.locationhttps://developer.mozilla.org/en-US/docs/Web/API/window.location
When would you set window.location to a URL string versus setting window.location.href?
window.location.href = "http://www.stackoverflow.com"
Reference: https://developer.mozilla.org/En/DOM/Window.location