Standard reference
Htmlframeelement and htmliframeelement do not have the ' document ' attribute, as described in DOM-2.
For more information about Htmlframeelement objects, refer to the contents of DOM-2 Interface htmlframeelement.
For more information about Htmliframeelement objects, refer to the contents of DOM-2 Interface htmliframeelement.
Problem description
Only IE Opera supports the use of the Htmlframeelement.document and Htmliframeelement.document properties to get the HTMLDocument object of the frames page. This property is non-standard.
The impact
If you attempt to get the HTMLDocument object of the frames page through the ' Document ' property of the Htmlframeelement and Htmliframeelement objects, you will get ' Undefin ' in Frirefox Chrome Safari Ed '.
The affected browser
IE6 IE7 IE8 Opera
Problem analysis
Analyze the following two sets of test code, each attempting to obtain the ' document ' attribute for Htmlframeelement and htmliframeelement:
" content-type " content=" text/html; Charset=utf-8 /><script> Window.onload =function () {alert (document.getElementById ( " frame " </script> " frame src=" _content.html /></frameset>
" content-type " content=" text/html; Charset=utf-8 /><script> Window.onload =function () {alert (document.getElementById ( " iframe " </script> iframe src=" _content.html ></iframe></body>
Of the above test cases, only IE6 IE7 IE8 Opera will get a HTMLDocument object for both (that is, the document object for the page within the frame), while the other browsers return ' undefined '.
Note: The above tests are not related to document mode.
Solution Solutions
Use the Contentwindow property of the Htmlframeelement or Htmliframeelement object to get the window object of the frame page applied, and then access the document object under it.
Change the ' xxx.document ' of the above test code to ' XXX.contentWindow.document ', such as:
"Content-type"Content="text/html; Charset=utf-8"/><script>window.onload=function () {alert (document.getElementById ("iframe"). contentwindow.document);};</script>"iframe"Src="_content.html"></iframe></body>BT9034: Only IE and Opera support the document properties of Htmlframeelement and Htmliframeelement