Forum Moderators: open

Message Too Old, No Replies

document.write to iframe

document.write/appendChild to iframe

         

yogesh

6:56 am on Jan 2, 2012 (gmt 0)

10+ Year Member



I have a iframe, in whose body, I have .js script containing document.write.

When I write to iframe from .js file I get following error in Firefox. It works in Chrome without any warning or error.
A call to document.write() from an asynchronously-loaded external script was ignored.


On
document.getElementById('myiframe').body.appendChild(myDiv)
, I get an error
Uncaught TypeError: Cannot call method 'appendChild' of undefined


Any ideas on how to write to iframe are much appreciated.

daveVk

10:14 am on Jan 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming the js is running within the iframe window, then window refers to the iframe.

window.document.body.appendChild(myDiv)

window. is optional.

penders

11:24 am on Jan 3, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a iframe, in whose body, I have .js script containing document.write.


Although the errors seem to suggest you are trying to run an external script that affects the content of the iframe?