In chrome if I have HTML as a string in a var named html I can easily just load it into an iframe and have the iframe execute that html page (with whatever css/jss/etc it might contain) by doing:
window.sHTML = html;
iframe.src = javascript:parent.sHTML
In Firefox this doesn’t work at all. Is there a way to do this that works in firefox? Note that I need the JS to execute properly in the iframe. For example this fiddle http://jsfiddle.net/9k9Pe/2/ kind of does what I want but if there is a script tag inside the html then that breaks things.
UPDATE: This actually does work in firefox, it just interacts differently with window.location which was breaking my code.
Answering my own question:
This actually does work in firefox, it just interacts differently with window.location which was breaking my code.
To go into more detail, in chrome if you do
Then the iframe will execute the html in the html string but its window.location will remain http://www.foo.com/bar.html and relative links will be treated as though the iframe were from http://www.foo.com/bar.html
However in FF the window.location becomes javascript:parent.sHTML and relative links will no longer work the way one expects.