0

I'm trying to do the following. Say I have html file and it contains blank iframe within it

<iframe id="preview"></iframe>

Now I need to write a script to update content of that iframe

var preview=document.getElementById("preview");
    preview.src = 'data:text/html;charset=utf-8,' + HTML_CODE_HERE;

Problem occurs when that code contains external CSS or javascript files, they just appear to not parse / execute.

How can I make iframe reload and re-run HTML parser for it's content?

  • I found a solution here: http://www.zomeoff.com/javascript-how-to-load-dynamic-contents-html-string-json-to-iframe/ – Paja Kljunar Jan 18 '16 at 14:34

1 Answers1

0

Two things.

1.Why is the src of your iframe, an entire HTML page?Shouldn't you be creating an HTML page, say page1.html, and referring to that in your src?

2.You might be facing problems with external paths and CSS because the path that is given when the iframe is displayed.

3.For reloading an iframe, check this StackOverflow link.

Community
  • 1
  • 1
Satej S
  • 2,113
  • 1
  • 16
  • 22