Javascript:document.write(“hello world”) works at first but if you change the text it does not work for the next text.
To reproduce:
In your address bar:
-
Type http://nazmulweb.com or any other url
-
After loading the page, type Javascript:document.write(“hello world”)
-
Browser will show “hello world”, isn’t it?
-
Then type javascript:document.write(‘hello stackoverflow users!’)
This time the browser doesn’t update the text. What can be the reason?
“What is my target?”
I am using the following code to write in an Iframe
function writeInIframe(data){
var previewWindow=$("pwFrame").contentWindow;
if (previewWindow.document) {
previewWindow.document.open();
previewWindow.document.write(data);
previewWindow.document.close();
}
}
For the first time data is properly shown in the Iframe but later on, newly data is not updated in the Iframe.
From MDC: