Welcome to WebmasterWorld Guest from 184.108.40.206
Forum Moderators: open
joined:Aug 6, 2003
both work on my browser. but I wonder
if both will work on IE6 and which one is
The correct syntax is window.top.location - this is because 'top' is a property of the object 'window' (and 'location' is a property of 'top.') I'm not sure but I suspect that IE is incorrectly supporting the alternative top.window.location syntax.
I agree with daosmith that window.top.location is the right way, but here are some further thoughts, which can explain why both ways work:
window.top.location and window.location are both legal, according to the Gecko DOM ref. The difference only becomes apparent when your page is in a frame.
top.window.location also works because it probably defaults to something like this.top.window.location ... Not very elegant, but I think is is perfectly valid for IE to support it, and not a bug in IE.