views:

45

answers:

0

The javascript code below is called by an event in order to overwrite the contents of an iframe with id jj. It works properly. However, removing the calls to open() and close() cause the iframe to become blank every other time the code is called, at least in IE8 and FF3. Opera doesn't seem to care. What is going on here?

var a = document.getElementById("jj");
a.src = "about:blank";
a.contentWindow.document.open();
a.contentWindow.document.write("<h3>Preview:</h3>" + scripttxt + "");
a.contentWindow.document.close();