Difference between document.URL and location.href
62,316
They're interchangeable as far as getting data is concerned, but as you pointed out document.URL can not be set. I just always use location.href since it's a getter/setter.
Author by
eddie yang
Updated on September 23, 2020Comments
-
eddie yang almost 4 years
I know that
document.URL
can not be set, whilelocation.href
can.But the Document indicates:
URL is a replacement for the DOM Level 0
location.href
property.So when would we use
document.URL
?