JSFiddle - React, Tailwind, and code Playground
by John Schulz
HTML
<p>The iframe will should take 2 seconds to load</p>
<iframe id="theiframe" src="/ajax_json_echo/?iframe is loaded" width="100%"></iframe>
JavaScript
jQuery('#theiframe').load(externalJSFunction);
function externalJSFunction() {
alert('externalJSFunction was called');
var user_input = prompt('What you enter will be put in the iframe');
var iframe = document.getElementById('theiframe');
var local_document;
if (iframe.contentDocument) {
local_document = iframe.contentDocument;
} else if (iframe.contentWindow) {
local_document = iframe.contentWindow.document;
}
local_document.writeln(user_input);
console.log('local_document', local_document);
}