I have a JavaScript function that does a combination of AJAX and string manipulation to produce a full HTML page as a string. I.e.:
var markup='<html><body>Hello world!</body></html>';
That is very simplified and I cannot guarantee that the HTML structure is predictable. How can I display that content on the page? I think an iframe makes the most sense since string contains a full HTML page but I don’t know how to inject the markup into the iframe.
I don’t want to create another physical file just to use as a “proxy” so I am hoping for a solution that can be encompassed entirely in one HTML page.
works for me. I also did use
<object>s with a data-uri in theirdataattribute, e.g. to display xml documents:You also can use a
<object data="about:blank">instead of the iframe to get a contentDocument to overwrite.