Iframe.contentWindow.document An alternative to Chrome?

How can I name the following in Chrome? iframe.contentWindow.document

+6
javascript google-chrome iframe
source share
3 answers

iframe.contentDocument is what you want.

See also Chrome: getting an iFrame and pasting into the body

+6
source share

Chrome actually supports iframe.contentWindow.document , but there are some wrinkles that you probably fell victim to: if the file set to the iframe.src property is accessed locally (ie using the file "file: //" protocol), This property is not available in Chrome. This will happen if you specify the relative address of the file and try to test the script without using a web server such as IIS or Apache (just double-clicking it). The same goes for iframe.contentDocument .

I had a similar problem where, for some odd reason, Chrome did not accept event handlers dynamically associated with iframes. Then I found the note in this article tested using Apache, and unfortunately it started working.

+6
source share
 <iframe id="popupFrame" /> <script type="text/javascript"> var popupFrame = document.getElementById('popupFrame'); var iFrameDoc; if (switchAccountsPopupFrame.document) { iFrameDoc = switchAccountsPopupFrame.document; // works with IE9 and FF9 } else { // Google Chrome (16.0.912.75 m) iFrameDoc = switchAccountsPopupFrame.ownerDocument; } .... </script> 
-one
source share

All Articles