I know that document.URL
can not be set, while location.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
?
I know that document.URL
can not be set, while location.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
?
You can get the document.URL, but you can not set it. You can both get and set the
location.href
.In some webbrowsers, you are able to set the
document.URL
but please don't, as it doesn't work in most browsers.You gave the answer yourself!
Learn more here
Yes and no!
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.