InterviewHubPRO
Section Overview
Q297

Question 297 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

57%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

How do you invoke javascript code in an iframe from the parent page

Initially iFrame needs to be accessed using either document.getElementBy or window.frames. After that contentWindow property of iFrame gives the access for targetFunction

javascript
  document.getElementById("targetFrame").contentWindow.targetFunction();
  window.frames[0].frameElement.contentWindow.targetFunction(); // Accessing iframe this way may not work in latest versions chrome and firefox