Is top.location cross browser?

N

nntp

Assuming JS is enabled, what is the most cross browser for changing the
location of the page? I am currently use top.location. Works fine in IE 6,
Firefox 9, Opera 7, but I am not sure about older or other browers, like Mac
browser.

this.location
top.location
document.location
_top.location
 
F

Fred Oz

nntp said:
Assuming JS is enabled, what is the most cross browser for changing the
location of the page? I am currently use top.location. Works fine in IE 6,
Firefox 9, Opera 7, but I am not sure about older or other browers, like Mac
browser.

this.location
top.location
document.location
_top.location

The oldest Mac browser I have is IE, I guess I could test NS 4 if I
could find somewhere to download it from and you're really desperate.

I tested top.location in the following Mac browsers (listed in
alphabetical order for no particular reason):

Camino 0.7
Firefox 0.9.1
Internet Explorer 5.2.2
Mozilla 1.7
Netscape 7.2
Omniweb 5.0.1
Opera 6.03
Safari 1.0.3

Cheers, Fred :)
 
N

nntp

this.location
The oldest Mac browser I have is IE, I guess I could test NS 4 if I
could find somewhere to download it from and you're really desperate.

I tested top.location in the following Mac browsers (listed in
alphabetical order for no particular reason):

Camino 0.7
Firefox 0.9.1
Internet Explorer 5.2.2
Mozilla 1.7
Netscape 7.2
Omniweb 5.0.1
Opera 6.03
Safari 1.0.3

Cheers, Fred :)

TESTED? Result? All passed?
I appriciate your time. Thank.
 
F

Fred Oz

nntp said:
TESTED? Result? All passed?
I appriciate your time. Thank.

Sheesh, always with the questions... :)

I realise I shoulda added "and they all passed".

Cheers, Fred.
 
V

VK

To address the same page where the script itself resides:
self.location.href = newURL;

To address another page in a frameset:
window.top.frameName.location.href = newURL;
or (hypercorrect):
window.top.frames['frameName'].location.href = newURL;

top.location addresses the topmost frame, which is semi-OK if there are no
frames (=self) or if you indeed want to replace the whole frameset with the
new address.
Otherwise the results will not be as expected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top