Is it possible to load content into an iframe and load the iframe to render the content?

26 views
Skip to first unread message

Devan Shah

unread,
May 15, 2016, 10:04:37 PM5/15/16
to karma-users
Hello

I am trying to inject a full html document into an iframe, like so:

var unitTestcaseHTML = "<full html document with all the tags and all>";

var iframe = document.createElement('iframe');
iframe.id = "unitTestcaseIframe";
document.body.appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(unitTestcaseHTML);
iframe.contentWindow.document.close();

When I do this, in the testcase it self I am not able to access the iframe document with the content that I provided it keeps getting empty content. However when I open it in debug it looks like everything is rendered and I can see it all.

Thanks
Devan

Devan Shah

unread,
May 15, 2016, 10:15:22 PM5/15/16
to karma-users
Ignore This, I figured it out
Reply all
Reply to author
Forward
0 new messages