controlling an iframe from another iframe within a frame

J

James Wallace

I need to know how to change the src property of an iframe from script
that is executed in another iframe with both of these iframes being
contained on a document which is then contained by another frame. I
have done a bunch of searching on these groups all to no avail.
I am new to javascript and learning so if someone can help me with
this I would appreciate it.
 
W

William Morris

What you need to learn to do is navigate the document hierarchy, which is
pretty simple once you get the hang of it. It should also be noted that
unless you're willing to work with one browser and one browser only, you're
not going to enjoy all the coding that makes this cross-browser compatible.
For IE only, if I have an HTML file with an iFrame and I want to refer to
that iFrame, I do this:

document.myFrame.location = "http://www.yahoo.com"

If I want to refer back to the document from my iframe, I do this in the
iframe code:

parent.somesetting.somevalue = 'some new value'

To refer to a second iframe from the first iframe:

parent.secondIframe.location = "http://www.google.com"

To refer to the containing frame of the parent document of either iframe:

parent.parent.someSetting.value = 'some new value'

See how that works for you...

- Wm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top