Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling iframe function

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

like image 540
haddar Avatar asked Sep 13 '26 01:09

haddar


1 Answers

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().

like image 92
Paulo Santos Avatar answered Sep 14 '26 15:09

Paulo Santos