{"id":541,"date":"2010-10-31T21:20:34","date_gmt":"2010-10-31T21:20:34","guid":{"rendered":""},"modified":"2010-10-31T21:20:34","modified_gmt":"2010-10-31T21:20:34","slug":"541","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=541","title":{"rendered":"iframe\u81ea\u9002\u5e94\u5185\u5c42\u9875\u9762\u9ad8\u5ea6\uff0c\u53ef\u54cd\u5e94\u9875\u9762\u4e2d\u6298\u53e0\u70b9\u51fb\u4e8b\u4ef6\uff0c\u4ee5\u53ca\u5b9e\u73b0\u8de8\u57df\u7684\u95ee\u9898\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"<p>\u4e00\u3001\u7236\u9875\u9762\u548c\u5185\u5bb9\u9875\u5728\u540c\u4e00\u57df\u540d\u5730\u5740\u4e0b\u7684\u60c5\u51b5\uff0c\u9875\u9762\u53d1\u751f\u70b9\u51fb\u4e8b\u4ef6\u540e\u81ea\u52a8\u8c03\u8282\u7236\u9875\u9762\u9ad8\u5ea6[\u6b64\u65b9\u6cd5\u4e0d\u53ef\u5b9e\u73b0\u8de8\u57df]<\/p>\n<p><code><br \/>&lt;iframe id=\"iframe1\" onload=\"addEvt(this)\" src='[\u60a8\u7684\u5f15\u7528\u9875\u9762\u5730\u5740]'&nbsp;&nbsp; frameborder='0' marginheight='0' marginwidth='0' width='100%' height='600px' scrolling='no'&gt;&lt;\/iframe&gt; <br \/>&lt;script type=\"text\/javascript\"&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>function addEvt(ifr) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>var doc = ifr.contentWindow.document;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>doc.onclick = function() {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>ifr.style.height = (document.all ? doc.body.scrollHeight : doc.body.offsetHeight) +&nbsp;&nbsp; 'px';&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>ifr.style.height = (document.all ? doc.body.scrollHeight : doc.body.offsetHeight) +&nbsp;&nbsp;'px';&nbsp;&nbsp;&nbsp;&nbsp;}&lt;\/script&gt;<br \/><\/code><\/p>\n<p>\u4e8c\u3001iframe\u8de8\u57df\u7684\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p>\u5047\u8bbe\uff1a\u6211\u4eec\u8981\u5e94\u7528Iframe\u7684\u9875\u9762\u4e3a:a.html \u57df\u540d\u4e3a\uff1awww.a.com ; \u8981\u5d4c\u5165\u7684\u9875\u9762\u4e3acontent.html;\u4e2d\u95f4\u9875\u9762\u4e3aiframe.html<\/p>\n<p>a.html\u4e2d\u7684\u5185\u5bb9<\/p>\n<p><code><br \/>&lt;iframe id=\"iframe1\" src='[\u5f15\u7528\u9875\u9762\u5730\u5740]' frameborder='0' marginheight='0' marginwidth='0' width='100%' height='600px' scrolling='no'&gt;&lt;\/iframe&gt;<br \/><\/code><\/p>\n<p>* \u6b64\u65f6\u6211\u4eec\u9700\u8981\u5efa\u7acb\u4e00\u4e2a\u4e2d\u95f4\u9875\u9762iframe.html,\u628a\u8fd9\u4e2a\u6587\u4ef6\u653e\u5728www.a.com\u4e0b,\u4e5f\u5c31\u662f\u548ca.html\u5728\u540c\u4e00\u57df\u540d\u4e0b\u7684\u76ee\u5f55<\/p>\n<p>iframe.html\u4e2d\u7684\u5185\u5bb9 <\/p>\n<p><code><br \/>&lt;script type=\"text\/javascript\"&gt; <br \/>var b_iframe = window.parent.parent.document.getElementById(\"c_iframe\");&nbsp;&nbsp;\/\/\u6b64\u5904\u4e3acontent.html\u4e2diframe\u7684ID <br \/>var hash_url = window.location.hash; <br \/>var hash_width = hash_url.split(\"#\")[1].split(\"|\")[0]+\"px\"; <br \/>var hash_height = hash_url.split(\"#\")[1].split(\"|\")[1]+\"px\"; <br \/>b_iframe.style.width = hash_width; <br \/>b_iframe.style.height = hash_height;&lt;\/script&gt;<br \/><\/code><\/p>\n<p>content.html\u4e2d\u7684\u5185\u5bb9<\/p>\n<p><code><br \/>&lt;iframe id=\"c_iframe\"&nbsp;&nbsp;height=\"0\u2033 width=\"0\u2033&nbsp;&nbsp;src=\"<a href=\"http:\/\/www.a.com\/iframe.htm\" target=\"_blank\" rel=\"external\">http:\/\/www.a.com\/iframe.htm<\/a>\" style=\"display:none\" &gt;&lt;\/iframe&gt;<br \/>&lt;script type=\"text\/javascript\"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>var b_width = Math.max(document.body.scrollWidth,document.body.clientWidth);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>var b_height = document.all ? document.body.scrollHeight : document.body.offsetHeight;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>var c_iframe = document.getElementById(\"c_iframe\");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>c_iframe.src = c_iframe.src + \"#\" + b_width + \"|\" + b_height;&lt;\/script&gt;<br \/><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u7236\u9875\u9762\u548c\u5185\u5bb9\u9875\u5728\u540c\u4e00\u57df\u540d\u5730\u5740\u4e0b\u7684\u60c5\u51b5\uff0c\u9875\u9762\u53d1\u751f\u70b9\u51fb\u4e8b\u4ef6\u540e\u81ea\u52a8\u8c03\u8282&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-541","post","type-post","status-publish","format-standard","hentry","category-Note"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=541"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}