从父文档/窗口调用IFrame Javascript函数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从父文档/窗口调用IFrame Javascript函数相关的知识,希望对你有一定的参考价值。

This snippet lets you call a javascript function declared within an IFrame from the parent element of the IFrame
  1. var iframe = document.getElementById("myframe");
  2. if (iframe) {
  3. var iframeContent = (iframe.contentWindow || iframe.contentDocument);
  4.  
  5. iframeContent.targetFunction();
  6. }

以上是关于从父文档/窗口调用IFrame Javascript函数的主要内容,如果未能解决你的问题,请参考以下文章