PDA

View Full Version : changing javascript to open outside iframe


Allute
02-02-07, 08:21 PM
I've got a code at this website: http://www.web-source.net/javascript_redirect_box.htm

I want to put it in the navigation bar that is set up as an iframe, but I don't know what to change to get it to open the pages outside of the iframe.

MattCoz
02-02-07, 09:24 PM
Use this:

parent.location=form.select.options[index].value;

Allute
02-02-07, 11:41 PM
Thanks mucho! That worked perfectly. I'm assuming the "parent" added to the beginning of the line of code there tells the script to open in the parent frame?

kayson
02-02-07, 11:46 PM
Yeah. Parent refers to the parent of the object from which you're referring the property according to the JavaScript hierarchy. Typically when called from within a document, parent usually refers to the outermost object which is window.

Allute
02-03-07, 07:48 AM
and what would I put to have it open inside a new window?

kayson
02-03-07, 11:37 AM
You could do it through your <a> tag. Just add the "target" attribute.


<a href="url" target="_NEW">Text</a>

That will open a new window. You can also use the same thing to have links from the iframe control the main window and vice versa.