I'm trying to create an empty iframe fill it with some html-code (here: "Hello World")
using javascript.
The script file is hosted at domain a.com
and loaded from a website at b.net
.
All the other js code works but when I try to set the iframe's content, I get an cross origin error. Is there a propper workaround which works?
var node = document.createElement("iframe");
node.setAttribute("border", "0px");
node.setAttribute("sandbox", "");
node.setAttribute("id", "preload");
var obj = document.getElementsByTagName("footer")[0].appendChild(node);
node.contentWindow.document.open();
node.contentWindow.document.write("Hello World");
node.contentWindow.document.close();