JavaScript Tip of the Week for December 16, 1996: Those Little Odds And Ends | 2 | WebReference

JavaScript Tip of the Week for December 16, 1996: Those Little Odds And Ends | 2

JavaScript Tip of the Weekfor December 16, 1996: Those Little Odds And Ends

Many a time has this question appeared in my inbox: How do I get the [select menu / billboard / whatever else] to target a link in [another frame / another window / the top window]? I think you get the picture. Well, the answer is easy. In most tips that deal with changing the location of a page, such as the select menus and billboard tip, you will find a line of code that looks something like this:
    window.location = what follows is irrelevant...
This simple line is used on pages across the web to change the location of the current window to a different location. There are variations on it: self.location, window.location.href, etc. Most of these preform basically the same task. However, there are a few variations on this simple line of code that can have a big impact on what it does. For instance, you want to make the select menu change another frame, as opposed to the one it is currently located in, change this line:
    window.location = ...
To this:
    parent.framename.location = ...
In place of framename put the exact name of the frame that you wish to change the location of. What this code says is this, "Look at the current FRAMESET, then look for the frame named 'framename' and set it's location to..." Similarly, if you wish to clear all the frames, like the effect you get when you use TARGET = "_top", use this line of code:
    parent.location = ...
This changes the location of the current FRAMESET, clearing all of the current frames. If you have nested frames, in place of parent put top. Including top will change the location of the uppermost browser window, not just the current FRAMESET. I hope this has answered your question, or any future questions you may have about using the select menus and billboards to target frames.