Document.location.href or document.URL

Which is the better option to use when dynamically loading a page?

document.location.href = “newpage.html”

or

document.URL = “newpage.html”

My book says that Netscape depreciated document.location.href in favour of document.URL, but yahoo are using document.location.href.

Also, is there a good online reference (up-to-date) of the DOM which includes stuff like this?

Originally posted by dale_burrell
[B]Which is the better option to use when dynamically loading a page?

document.location.href = “newpage.html”

or

document.URL = “newpage.html”

My book says that Netscape depreciated document.location.href in favour of document.URL, but yahoo are using document.location.href.

Also, is there a good online reference (up-to-date) of the DOM which includes stuff like this? [/B]

It actually should be “window.location.href” or just “location.href” (the window object is always implied). You may have an old book, as “document.URL” was the one that has been deprecated.

–Vinnie

Can you recommend somewhere online to obtain this kind of info?

http://www.w3.org/DOM/

Everything you need to know, and probably a lot that you don’t. The W3C is VERY thorough on their specs.

–Vinnie

Ar yes, the spec, know about that. Found it a bit hard to understand.

Anything simplier around?

Actually AFAICS the spec says that an HTMLDocument has a URL attribute not a location attribute?

Originally posted by dale_burrell
[B]Ar yes, the spec, know about that. Found it a bit hard to understand.

Anything simplier around?

Actually AFAICS the spec says that an HTMLDocument has a URL attribute not a location attribute? [/B]

location is a property of the window object, which is why you don’t see it in the HTMLDocument spec.

–Vinnie

You may also want to check out Netscape’s developer site. I can’t remember the exact URL now but it contains a lot of info on Javascript and the DOM.

–Vinnie