![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Cracked it! My JS book (O'Reilly) implies that window.location returns a string, but it doesn't! |
#12
| |||
| |||
|
|
(window.)location is in recent user agents a string value *and* an object with properties like `href', `protocol', `path', `hash' aso. Here, in Mozilla/5.0 rv:1.5 and IE 6.0 SP-1, it is. Which user-agent are you testing with? |
#13
| ||||
| ||||
|
|
Thomas 'PointedEars' Lahn <PointedEars (AT) web (DOT) de> writes: (window.)location is in recent user agents a string value *and* an object with properties like `href', `protocol', `path', `hash' aso. Here, in Mozilla/5.0 rv:1.5 and IE 6.0 SP-1, it is. Which user-agent are you testing with? In my IE6, it is only an object. It doesn't have the methods from String.prototype (e.g., charAt), and its typeof is "object". |
|
If you convert it to a string, either with String(location), location.toString() or ""+location, the resulting string contains the URL, but that just means that it can be converted to a string. |
|
There is some magic to the location object, though, since *assigning* to it will really assign to location.href. |
See|
As a curiosity, in Opera 7 the location.valueOf method is the same as the location.toString. |
#14
| |||
| |||
|
|
In contrast, in older UAs like Opera 6 (IIRC), `location' stores only a primitive string value. |

|
There is some magic to the location object, though, since *assigning* to it will really assign to location.href. There is no magic involved Seehttp://devedge.netscape.com/library/.../location.html |
|
As a curiosity, in Opera 7 the location.valueOf method is the same as the location.toString. Same in Mozilla/5.0 and IE 6.0 SP-1, as expected. |
#15
| ||||||||
| ||||||||
|
|
Thomas 'PointedEars' Lahn <PointedEars (AT) web (DOT) de> writes: In contrast, in older UAs like Opera 6 (IIRC), `location' stores only a primitive string value. YRI (You Remember Incorrectly ![]() |
|
In Opera 4, 5 and 6, location is an object. |
|
I don't have Opera 3 installed, |
|
The same goes for Netscape 4 and 3. |
|
There is some magic to the location object, though, since *assigning* to it will really assign to location.href. There is no magic involved Seehttp://devedge.netscape.com/library/.../location.html Tha qualified as "magic" to me (something that depends on internal code and cannot be implemented by a Javscript programmer, |
|
It says: --- If you assign a string to the location property of an object, JavaScript creates a location object and assigns that string to its href property. --- That is not correct for *any* object. The following gives me "string": --- var x = {}; // or var x=document.body; x.location = "foo"; typeof x.location --- So, it is only for window objects, not any object. |
|
The location object is contained by the window object and is within its scope. If you refer to a location object without specifying a window, the location object represents the current location. If you refer to a location object and specify a window name, as in windowReference.location, the location object represents the location of the specified window. |
|
As a curiosity, in Opera 7 the location.valueOf method is the same as the location.toString. Same in Mozilla/5.0 and IE 6.0 SP-1, as expected. In my IE 6, the location object doesn't have a valueOf property. |
#16
| ||||
| ||||
|
|
Because you cannot rely on what iteration shows, is there a way to get all properties of an object other than brute force, and if that, how it is done? |
|
I don't have Opera 3 installed, See [1]. |

|
It also says: | The location object is contained by the window object and is within its | scope. If you refer to a location object without specifying a window, the | location object represents the current location. If you refer to a | location object and specify a window name, as in windowReference.location, | the location object represents the location of the specified window. |
|
and BTW, your `x' is not a Location object. |
#17
| |||
| |||
|
|
Because you cannot rely on what iteration shows, is there a way to get all properties of an object other than brute force, and if that, how it is done? No. You can only get the enumerable properties. For the rest, you must do a brute force search (i.e., you can't in practice). snip |
#18
| |||
| |||
|
|
Do you really mean you can't in practice? Certainly it would not be practical to test every combination of character sequence that could be a property name (the end on the universe would arrive before the results), |
|
but I don't see a problem with trying each item in a list of likely property names against an object to see which return non-undefined values. |
|
Then the usefulness of the results only depends on the quality of the list of likely property names. It wouldn't be quick but it wouldn't be so slow as to be impractical. |

#19
| |||
| |||
|
|
In comp.lang.javascript, Thomas 'PointedEars' Lahn wrote: Time zones don't enter into it, all users are in the UK. I wonder how you can be sure. Because it is a campaign site for broadband in Kent. |
![]() |
| Thread Tools | |
| Display Modes | |
| |