-2

I tried this code: document.getElementById('targetFrame').contentWindow.targetFunction(); from here but it seems like you have to put it outside of the iframe. How can you do it only in the iframe and not anything outside of it?

1 Answers1

0

You can't.

The only way a code in a frame can communicate with parent page and vice versa, is via postMessage()

vanowm
  • 9,466
  • 2
  • 21
  • 37