Call IFrame Javascript function from parent document/window


/ Published in: JavaScript
Save to your folder(s)

This snippet lets you call a Javascript function declared within an IFrame from the parent element of the IFrame


Copy this code and paste it in your HTML
  1. var iframe = document.getElementById("myframe");
  2. if (iframe) {
  3. var iframeContent = (iframe.contentWindow || iframe.contentDocument);
  4.  
  5. iframeContent.targetFunction();
  6. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.