JSFiddle - React, Tailwind, and code Playground
HTML
<div id="body"></div>
<input id="button" type="button" value="Reload iframe"/>
CSS
iframe {
height: 300px;
width : 100%;
}
JavaScript
var iframe = $("<iframe></iframe>").appendTo("#body")[0];
var doc = iframe.document;
var content = '<form method="get" action="http://bugs.jquery.com/ticket/13936/"><input value="form"/></form>';
doc = iframe.contentDocument;
doc.writeln(content);
doc.close();
$('input#button').click(function () {
try {
// selection attempt
var $iframe = $("iframe");
// repeat guard
if ( /again/.test( this.value ) ) {
alert("PASS");
return;
}
// iframe reload
$iframe.contents().find('form')[0].submit();
this.value = "Now try again...";
} catch ( x ) {
alert( x.message || x );
}
});