rahul888
rahul888

Reputation: 413

Can iframe display complex HTML code as a string.?

What I meant is that I am using this piece of code:

var textBody = $(printstr);
var iframeBody = $('#test').contents().find('body');
iframeBody.append(textBody.html());

To append Html String to the iframe and display it as a webpage.

I am successful if I am trying to

var s="<BODY>
<p>Hello Worlds</p>
</BODY>"

to the page, but I am not sucessfull in complex pages like, say I get this (current) Stack overflow page as a string and try to display it in the iframe. Can I do this..??

Upvotes: 0

Views: 316

Answers (1)

Deva
Deva

Reputation: 66

This will give you an idea about how to achieve this.

var text = "<h1>Hello World</h1>"; //Replace with your content
var node=document.createTextNode(text);
frame.document.body.appendChild(node);//setting iframe content

Upvotes: 1

Related Questions