Call iframe function

Is there a way to call a JavaScript function inside an IFrame from the parent?

+3
source share
3 answers

It depends on the contents of the IFrame. If the content is from a different domain, you are out of luck, as most modern browsers have closed this loophole for cross-site attacks.

However, if the content is in the SAME domain, you can use it as just another method for an IFrame window. If I remember correctly, you can use something like window.frames["_your_IFrame_ID_"].window.functionOrMethodName().

+8
source

Where do you want the function to be called? Moreover, what do you want to do?

, , 1) ? 2) IFrame 3) , , .

1)

2) , .

3) .

0

As far as I know, this is quite complicated. You can configure Cross-Domain Communication Channel . For Facebook applications, this kind is quite common. This, of course, only works if both sites play together.

0
source

Source: https://habr.com/ru/post/1726447/


All Articles