2

I am actually getting the html template dynamically on the fly, so my concern is how would I be able to append the html code to an iframe's src.

I followed up with some other question in the community and I could make jsFiddle , this is working fine for a single line of html template like

<html><head><title></title></head><body><h1>Hello world.</h1></body></html>

but when I a trying to add the little long length html template then the template is showing out of the iframe ,please check here .

2
  • Possible duplicate of dynamically set iframe src Commented Sep 11, 2017 at 8:46
  • Out there they are just adding the links for src parameter in iFrame which I already mentioned in the question and I have a solution here Commented Sep 11, 2017 at 8:49

1 Answer 1

1

Use like below

doc.write('<!DOCTYPE html>'+ ''+ ''); 

Like this

doc.write('<!DOCTYPE html>'+ '<html lang="en">'+ '<head>'); 

New line is breaking your javascript function

Sign up to request clarification or add additional context in comments.

6 Comments

I am getting the html template on the fly , I can't add "+" to the lines.
create function like this post stackoverflow.com/questions/805107/…
How you are getting this content in variable?
yes. actually I have form once the user fills that form we are putting that details as HTML file and then this has to be shown in another page in an iFrame.
For that you can read that html file in one variable in javascript then you can directly append that variable in iframe in that case it will not be new line but escaped with characters so
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.