When I try to access the iframe, I get this error and I'm not sure what i'm doing wrong. Can someone help me out with this problem?
var ifrm = document.getElementById('iframe'), ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument; ifrm.open(); ifrm.write("Hello World!"); ifrm.close(); These are the errors I recieve:
Uncaught TypeError: Cannot read property 'document' of undefined
Uncaught TypeError: Cannot read property 'readyState' of undefined
iframe.contentWindowis not cross-browser?ifrmis a reference to an iframe node (likevar ifrm = document.querySelector('iframe')for example). In that case you can have:ifrm.contentDocumentorifrm.contentWindow.document.