I'm trying to dynamically add an iframe with HTML to an existing page. I have gotten the iframe to load and show. However the "Body" of the iframe does not show. Any help?
<html>
<head>
<script>
window.onload = function() {
var iframe = document.createElement('iframe');
var html =
'<html><head>' +
'<scr' + 'ipt src="https://localhost:44302/foo.js"></scr' + 'ipt>' +
'<scr' + 'ipt src="https://localhost:44302/bar.js"></scr' + 'ipt>' +
'</head>' +
'<body>Hi</body></html>';
iframe.src = 'data:text/html;charset=utf-8,' + encodeURI(html);
document.body.appendChild(iframe);
console.log('iframe.contentWindow =', iframe.contentWindow);
}
</script>
</head>
<body></body>
</html>