Re: document.URL functionality
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: document.URL functionality

From: alu <none@none.com>
Date: Wed Aug 03 2005 - 16:18:36 CEST

"VK" <schools_ring@yahoo.com> wrote
>> alu wrote:
> > Could someone explain the discrepancies within and between the stated
> > definitions / usage of 'document.location' , 'document.URL' vs. their
actual
> > functionality?
> > Should they be read-only when in fact they are not?
>
> Originally (LiveScript - JavaScript 1.1) window.location was read-only
> and document.location was read-write. Now they both are read-write.
> This definitely makes easier to manupulated framed sites.

Not according to the Mozilla documentation, which states document.location
is read-only.

> > Is 'document.URL' also deprecated, and should therefore never be used?
>
> It is not deprecated, just an opposite it is rather newly introduced as
> substitution for document.location.href = newURL.
> But I would not suggest to use it as being one of ugly and unwanted
> children of W3.

I agree, it's behaviour is flakey at best.

> > What is the last word re: the proper syntax for returning and setting
the
> > current window's location?
>
> location is not a property. It's an object with a set of read-write
> string properties:
> href : the whole URL string
> protocol : http:, shttp:, file: etc.
> host : host name and port number (if presented)
> hostname : host name (if no post number, then == host)
> port : port number
> pathname : all between host and including the actual http page
> hash : anchor mark (what follows # sign)
> search : CGI request (what follows ? sign)
>
> All these parts can be read or change independently.
> The default property of location is href. So if you assign:
> document.location = newURL
> internally browser will treat it as:
> document.location.href = newURL

But document.location is deprecated - why use it at all?

> This way
> document.location = newURL
> document.location.href = newURL
> document.URL = newURL
> are alias of the same action.

In practice they are definitely not the same. Check the tests I posted.

>From the other side location is in use since the beginning of script
> and it allows you fine-graned access/change of of the URL parts.
> document.URL is a rather late invention of someone bored mind. It
> doesn't give you anything extra, but it takes out a lot. Just forget it.

Excellent.
-alu
Received on Tue Oct 18 03:04:51 2005