views:

108

answers:

4

Is there a way to call a javacript function that is inside an IFrame from the parent ?

A: 

no, it is not possible!

Newbie
+3  A: 

That depends on the contents of the IFrame. If the content is from another domain then you're out of luck, as most modern browsers have closed that loophole for cross-site attacks.

However, if the content is from the SAME domain then you can use it as it were simply another method on the IFrame window object. If I recall correctly you can use something like window.frames["_your_IFrame_ID_"].window.functionOrMethodName().

Paulo Santos
A: 

Where are you wanting the function to be called against? Moreover, what are you wanting it to do?

When you call it are you wanting it to 1) Operate on items in the container page? 2) Operate on items in the IFrame itself 3) Be a generic function accessible by both container and frame.

As far as I am aware

1) Isn't possible

2) Might be possible, given Paulo Santos' answer.

3) Should put function in a common file.

James Wiseman
A: 

As far as I know is this rather complicated. You can set up a Cross Domain Communication Channel. For Facebook applications this kind of thing is quite common. This, of course, only works if both sites play along.

RamboNo5