Home > Web Front-end > JS Tutorial > Code for accessing the document object of iframe in html in js [IE6, IE7, IE8, FF]_javascript skills

Code for accessing the document object of iframe in html in js [IE6, IE7, IE8, FF]_javascript skills

WBOY
Release: 2016-05-16 18:12:32
Original
980 people have browsed it


W3C standards tell us that the document object can be returned through the contentDocument attribute of the Dom object.
That is,

Copy code The code is as follows:

doc= document.getElementById('myframe ' ).contentDocument


But for IE browser, after testing, IE6 and IE7 are not supported, and IE8 starts to support it.
Under IE, you need to access
Copy the code The code is as follows:

document .frames['myframe'].document;


The cross-browser solution is the
contentWindow property, which is a read-only property that returns the window object of the specified iframe.
Although it is not part of the standard, it is supported by all major browsers.
So the method to access the iframe document object across browsers is
Copy the code The code is as follows:

document.getElementById( 'myframe').contentWindow.document
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template