I get an HTML string in my Javascript/JQuery script which is the complete HTML of a document. I need to display this HTML inside a <div>
in my web page.
For example, my Javascript is like:
// code ...
var htmlString = "<!DOCTYPE html><html><head><title>something</title>...other html tags...</head><body>...</body></html>";
// code...
I need to render the html string (the value of var htmlString
) in a particular <div>
in my webpage.
My idea is that in order to display an HTML page in another HTML page, we need to use iframe
. But iframe
gets a link to that webpage which is hosted somewhere. All I have is the HTML string of a complete HTML webpage, and I need to display it on my webpage in a <div>
.
How can I do that?