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.

LVL 12
Who is Participating?
jbirkConnect With a Mentor Commented:
I'm not entirely clear on what you're situation is, but I think this will do:
top.location = 'newpage.html';

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

j2Author Commented:
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?
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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).

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):
You can use the frames array with a number index (note that it start counting from 0):
You can simply use the name of the frame (assuming no invalid characters are in the name):

Hope that helps,
j2Author Commented:
Adjusted points to 20
j2Author Commented:
thanks a bunch. this was work a bit more then 10 points, so i added some.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.