Link to home
Start Free TrialLog in
Avatar of j2
j2Flag for Sweden

asked on

redirect _top from a frame.

I want to run a javascript in a frame that lives in another frameset of a page and i want it to redirect the 'entire' browser, and not just the frame.

How?
ASKER CERTIFIED SOLUTION
Avatar of jbirk
jbirk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jbirk
jbirk

If it doesn't work, please elaborate, and I'll come up with a different solution.

-Josh
Avatar of j2

ASKER

Yep, thats what i needed, before i give you the point,s i am just curious. Can you set a location for any give frame name like this somehow?
Yes, but only in the current window, or any windows which you have handles to (the javascript opener of current window, or any windows opened via javascript in this window).

If you start from the top frameset, you can trickle down the object path to change any specific frame.  You can also use the parent keyword to go up only one frameset at a time (insetad of jumping to the top frameset).

Example:
top.frames["framename"].frames["anotherframe"]....
or from a left nav frame to a right main frame:
parent.main.location = "new.html";

There are three ways of referencing frames (or any object actually) in JavaScript.

You can use the frames array with the frame name as a string (useful if the frame name contains invalid characters):
top.frame["frame-name"]
You can use the frames array with a number index (note that it start counting from 0):
top.frames[1]
You can simply use the name of the frame (assuming no invalid characters are in the name):
top.main


Hope that helps,
Josh
Avatar of j2

ASKER

Adjusted points to 20
Avatar of j2

ASKER

thanks a bunch. this was work a bit more then 10 points, so i added some.