BT9034: Only IE and Opera support the document properties of Htmlframeelement and Htmliframeelement

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.