Calling script from an IFrame to the parent frame 
Author Message
 Calling script from an IFrame to the parent frame

Hi,

The setup I have is a frame that has an IFrame inside it which loads another
asp page. What I would like to do at this point is if I click a button
inside the IFrame, it can navigate to the parent frame and run a function
there. Ideally I what also like to run code from the parent frame that
resides inside the IFrame. I've gone through the various object models but
still no luck finding a way to find and execute script.

Any help would be appreciated,

David
Mavpro.com



Sat, 18 Oct 2003 06:00:13 GMT  
 Calling script from an IFrame to the parent frame
From the Iframe to the parent is simple, just use "parent.somefunction()";

From the parent to the Iframe is confusing at first, because you probably
are trying to talk to it through something like this:

document.all.myIframe.somefunction(); // WRONG!!!

But that doesn't work, because you are talking to the Iframe-element in the
parent page and not to the Iframe's document

What you need is something like this:

document.frames['myIframe'].document.somefunction();

I hope this helps.

Regards,
Martin


Quote:
> Hi,

> The setup I have is a frame that has an IFrame inside it which loads
another
> asp page. What I would like to do at this point is if I click a button
> inside the IFrame, it can navigate to the parent frame and run a function
> there. Ideally I what also like to run code from the parent frame that
> resides inside the IFrame. I've gone through the various object models but
> still no luck finding a way to find and execute script.

> Any help would be appreciated,

> David
> Mavpro.com



Sun, 19 Oct 2003 02:39:02 GMT  
 Calling script from an IFrame to the parent frame


Fri, 19 Jun 1992 00:00:00 GMT  
 Calling script from an IFrame to the parent frame
Sorry, I should have tested it and see that I was in error.

What you must do is:

window.frames['myIframe'].somefunction('This is from the parent');

As you see, the "document." has dissapeared 2 times, the second one that
came just before "somefunction()" didn't work in any browser. The first must
be replaced with "window." for Netscape 6

Also for Netscape 6 you must give your iframe-tag a name property, so :
<iframe name=myIframe src=...

But you could also give it an ID property with the same value.

Regards,
Martin



Quote:
> From the Iframe to the parent is simple, just use "parent.somefunction()";

> From the parent to the Iframe is confusing at first, because you probably
> are trying to talk to it through something like this:

> document.all.myIframe.somefunction(); // WRONG!!!

> But that doesn't work, because you are talking to the Iframe-element in
the
> parent page and not to the Iframe's document

> What you need is something like this:

> document.frames['myIframe'].document.somefunction();

> I hope this helps.

> Regards,
> Martin


> > Hi,

> > The setup I have is a frame that has an IFrame inside it which loads
> another
> > asp page. What I would like to do at this point is if I click a button
> > inside the IFrame, it can navigate to the parent frame and run a
function
> > there. Ideally I what also like to run code from the parent frame that
> > resides inside the IFrame. I've gone through the various object models
but
> > still no luck finding a way to find and execute script.

> > Any help would be appreciated,

> > David
> > Mavpro.com



Sun, 19 Oct 2003 07:54:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. calling function in child frame from parent frame

2. How to call a function in iFrame from parent page

3. iframe and parent of its parent

4. parent's parent in an IFRAME

5. Calling a script in one frame from another frame

6. IFRAME parent????

7. passing info to parent window with IFRAME

8. Access to Parent DOM from within an iFrame

9. Error accessing parent functions/vars from IFRAME

10. IFRAME content hangs around on refresh but script in IFRAME is not available

11. Calling script between frames

12. Calling a Frame a Frame

 

 
Powered by phpBB® Forum Software