Code for accessing the iframe Document Object in html in js [IE6, IE7, IE8, FF]

Source: Internet
Author: User

<Iframe id = "myframe"> </iframe>
W3C standards tell us that the document object can be returned through the contentDocument attribute of the Dom object.
That is
Copy codeThe Code is as follows:
Doc = document. getElementById ('myframework'). contentDocument


However, IE6 and IE7 are not supported after tests, and IE8 is supported.
In IE, you need to access
Copy codeThe Code is as follows:
Document.frames['myframe').doc ument;


The cross-browser solution is,
ContentWindow attribute, which is a read-only attribute and returns the window object of the specified iframe.
Although it is not part of the standard, it is supported by mainstream browsers.
So the cross-browser access to iframe document objects is
Copy codeThe Code is as follows:
Document. getElementById ('myframe'{.content}{doc ument

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.