js create iframe element code example
Example 1: use javascript to control iframe elements
<iframe id="myIFrame" src="thispage.html"
width="100%" height="600"
frameBorder="2">
</iframe>
const iFrame = document.getElementById('myIFrame');
const buttonInIFrame = iFrame.contentWindow.document.getElementById('myButton');
iFrame.contentWindow.yourFunction();
Example 2: document.createElement('iframe');
var ifrm = document.createElement('iframe');
ifrm.setAttribute('id', 'ifrm');
var el = document.getElementById('marker');
el.parentNode.insertBefore(ifrm, el);
ifrm.setAttribute('src', 'demo.html');