It is a continuation of the technical help for creating a dropdown menu. In this case, the script is adapted so that it can be used on a site designed with frames.
Obsolete article: Today the use of frames is discouraged, at least of the traditional frames that are used in this article. The
This is a report that must be read after the report, published in . In that article we taught how to create a dropdown browser with a SELECT element from a form.
Many visitors have already used the script successfully, but some have written with a question about its use on a framed page. The question is that the browser only updates the frame it is in, and the interesting thing for them would be to update a different frame. It is a very logical problem since the browser is often placed so that it is always visible, in a frame where we have the navigation controls and the area that we want to update is the one corresponding to the main frame.
The only place we’re going to have to make changes is in the script that contains the function we call destination(). This function must be adapted so that we can change the page from a frame other than the one we are in.
In our previous example we did window.location = url to change the content of the frame where the browser was. Now we must change the window.location of a different frame to this one and to access the location of a different frame it is achieved through this chain of objects:
window.parent.frames.window.location
frames is an array of frames where the first frame in the FRAMESET would be frames, the second would be frames, and so on. In case it is not clear, let’s see with an example.
We have this FRAMESET
In the second frame we have the page that contains a drop-down menu. Since it is the second frame, we would access its location in this way:
window.parent.frames.window.location = url
The entire script would look like this:
function target(){
url = document.browser.sections.options.value
if (url != "no") window.parent.frames.window.location = url;
}
That’s it, we no longer need to change more things to meet our goals.
If you want, you can download an example of this help working. 2Kb