Iframe usage, iframe usage
1. The parent page calls the child page element.
$('a').contents().find("b")
(A indicates the id or class of iframe, and B indicates the sub-page)
2. The child page calls the elements of the parent page
$(window.parent.document).contents().find("c")
(C represents any element id or class of the parent page) 3. iframe highly adaptive
<iframe src="" allowtransparency="true" id='ifm' style="background-color: transparent" frameborder="0" scrolling="no"></iframe>
JQuery Method
$ ('# Ifm '). load (function () {$ (this ). height ($ (this ). contents (). find ("body "). height (); // The body can also be any element of the iframe subpage });
Js Method
function setIframeHeight(iframe) { if (iframe) { var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow; if (iframeWin.document.body) { iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; }; };};window.onload = function() { setIframeHeight(document.getElementById('ifm'));};