Home >Web Front-end >HTML Tutorial >iframe parent-child page operation-two easy-to-use methods-window.parent/oframe.contentWindow.document_html/css_WEB-ITnose

iframe parent-child page operation-two easy-to-use methods-window.parent/oframe.contentWindow.document_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:52:361551browse

I found a more useful method of operating iframe parent-child pages, record it


1. Parent page test.html



Get iframe var oframe = document. getElementById("main")


Get the subpage var child = oframe.contentWindow.document


Get the subpage Element var test = child.getElementById("test")


Get the child page height var childh = child .body.offsetHeight


Get the sub-page height


2. Sub-page iframe.html



Get the parent page var parent = window.parent.document


Note: The code needs to be placed on the server side to be compatible with Google Chrome


Statement:
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