{"id":2260,"date":"2017-10-30T17:13:56","date_gmt":"2017-10-30T09:13:56","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2260"},"modified":"2017-10-30T17:13:56","modified_gmt":"2017-10-30T09:13:56","slug":"iframe%e7%88%b6%e5%ad%90%e7%aa%97%e5%8f%a3%e4%ba%92%e7%9b%b8%e8%b0%83%e7%94%a8%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2260","title":{"rendered":"iframe\u7236\u5b50\u7a97\u53e3\u4e92\u76f8\u8c03\u7528\u603b\u7ed3"},"content":{"rendered":"<p>\n\t\u5173\u4e8e iframe \u7236\u7a97\u53e3\u548c\u5b50\u7a97\u53e3\u76f8\u4e92\u7684\u8c03\u7528\u65b9\u6cd5\uff0c\u6211\u8fd9\u91cc\u505a\u4e2a\u603b\u7ed3\uff0c\u65b9\u4fbf\u4ee5\u540e\u7528\u5230\u3002\n<\/p>\n<p>\n\t\u7236\u7a97\u53e3\u8c03\u7528iframe\u5b50\u7a97\u53e3\u65b9\u6cd5\n<\/p>\n<ol>\n<li>\n\t\tHTML\u8bed\u6cd5\uff1a&lt;iframe name=&quot;myFrame&quot; src=&quot;child.html&quot;&gt;&lt;\/iframe&gt;&nbsp;\n\t<\/li>\n<li>\n\t\t\u7236\u7a97\u53e3\u8c03\u7528\u5b50\u7a97\u53e3\uff1amyFrame.window.functionName();&nbsp;\n\t<\/li>\n<li>\n\t\t\u5b50\u7a97\u54c1\u8c03\u7528\u7236\u7a97\u53e3\uff1aparent.functionName();&nbsp;\n\t<\/li>\n<li>\n\t\t\u7b80\u5355\u5730\u8bf4,\u4e5f\u5c31\u662f\u5728\u5b50\u7a97\u53e3\u4e2d\u8c03\u7528\u7684\u53d8\u91cf\u6216\u51fd\u6570\u524d\u52a0\u4e2aparent.\u5c31\u884c\u3002\n\t<\/li>\n<\/ol>\n<p>\n\t\u4e0b\u9762\u662fiframe\u7236\u5b50\u7a97\u53e3\u6574\u5728\u4e00\u8d77\u7684\u4f8b\u5b50\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;html&gt; \r\n&lt;head&gt; \r\n&lt;script type=&quot;text\/javascript&quot;&gt; \r\n\tfunction say1() { \r\n\t\talert(&quot;parent.html------&gt;I&#039;m at parent.html&quot;); \r\n\t} \r\n\tfunction callChild() { \r\n\t\t\/\/document.frames(&quot;myFrame&quot;).f1(); \r\n\t\tmyFrame.window.say(); \r\n\t} \r\n\t\/\/ \u4e1a\u4f59\u8349\uff1awww.xttblog.com\r\n\tfunction say2(){ \r\n\t\talert(&quot;child.html---&gt;I&#039;m at child.html&quot;); \r\n\t} \r\n\tfunction callParent() { \r\n\t\tparent.say(); \r\n\t} \r\n&lt;\/script&gt; \r\n&lt;\/head&gt; \r\n&lt;body&gt; \r\n&lt;input type=button value=&quot;\u8c03\u7528child.html\u4e2d\u7684\u51fd\u6570say1()&quot; onclick=&quot;callChild()&quot;&gt; \r\n&lt;iframe name=&quot;myFrame&quot; src=&quot;child.html&quot;&gt;&lt;\/iframe&gt; \r\n&lt;input type=button value=&quot;\u8c03\u7528parent.html\u4e2d\u7684say2()\u51fd\u6570&quot; onclick=&quot;callParent()&quot;&gt; \r\n&lt;\/body&gt; \r\n&lt;\/html&gt;<\/pre>\n<p>\n\tiframe \u7236\u7a97\u53e3\u548c\u5b50\u7a97\u53e3\u76f8\u4e92\u7684\u8c03\u7528\u65b9\u6cd5\n<\/p>\n<p>\n\tIE\u4e2d\u4f7f\u7528\u65b9\u6cd5\uff1a\n<\/p>\n<ul>\n<li>\n\t\t\u7236\u7a97\u53e3\u8c03\u7528\u5b50\u7a97\u53e3\uff1aiframe_ID.iframe_document_object.object_attribute = attribute_value&nbsp;<br \/>\n\t\t\u4f8b\u5b50\uff1aonClick=&quot;iframe_text.myH1.innerText=&#039;http:\/\/www.xttblog.com&#039;;&quot;&nbsp;\n\t<\/li>\n<li>\n\t\t\u5b50\u7a97\u53e3\u8c03\u7528\u7236\u7a97\u53e3\uff1aparent.parent_document_object.object_attribute = attribute_value&nbsp;<br \/>\n\t\t\u4f8b\u5b50\uff1aonclick=&quot;parent.myH1.innerText=&#039;http:\/\/www.xttblog.com&#039;;&quot;&nbsp;\n\t<\/li>\n<\/ul>\n<p>\n\tFirefox\u4e2d\u4f7f\u7528\u65b9\u6cd5\uff1a&nbsp;\n<\/p>\n<p>\n\t\u4e0a\u9762\u5728IE\u4e0b\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u5728firefox\u4e0b\u4e0d\u6b63\u5e38\u3002\u5728firefox\u4e0b\uff0c\u5e94\u8be5\u662f\u5982\u4e0b\u8c03\u7528\u65b9\u6cd5\u3002\n<\/p>\n<ul>\n<li>\n\t\t\u7236\u7a97\u53e3\u8c03\u7528\u5b50\u7a97\u53e3\uff1awindow.frames[&#8220;iframe_ID&#8221;].document.getElementById(&quot;iframe_document_object&quot;&shy;).object_attribute = attribute_value&nbsp;<br \/>\n\t\t\u4f8b\uff1a window.frames[&#8220;iframe_text&#8221;].document.getElementById(&quot;myH1&quot;).innerHTML= &quot;http:\/\/www.codedq.net&quot;;&nbsp;\n\t<\/li>\n<li>\n\t\t\u5b50\u7a97\u53e3\u8c03\u7528\u7236\u7a97\u53e3\uff1aparent.document.getElementById(&quot;parent_document_object&quot;).object_attribute = attribute_value&nbsp;<br \/>\n\t\t\u4f8b\uff1a parent.document.getElementById(&quot;myH1&quot;).innerHTML = &quot;http:\/\/www.codedq.net&quot;;&nbsp;\n\t<\/li>\n<\/ul>\n<p>\n\t\u65f6\u95f4\u5173\u7cfb\uff0c\u76f8\u5173\u4f8b\u5b50\u5c31\u4e0d\u5728\u8d34\u4e86\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2260\">iframe\u7236\u5b50\u7a97\u53e3\u4e92\u76f8\u8c03\u7528\u603b\u7ed3<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e iframe \u7236\u7a97\u53e3\u548c\u5b50\u7a97\u53e3\u76f8\u4e92\u7684\u8c03\u7528\u65b9\u6cd5\uff0c\u6211\u8fd9\u91cc\u505a\u4e2a\u603b\u7ed3\uff0c\u65b9\u4fbf\u4ee5\u540e\u7528\u5230\u3002 \u7236\u7a97\u53e3\u8c03\u7528iframe\u5b50\u7a97\u53e3 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[814,119,1559,1106],"class_list":["post-2260","post","type-post","status-publish","format-standard","hentry","category-html5","tag-css3","tag-html5","tag-iframe","tag-javascript"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2260"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2260\/revisions"}],"predecessor-version":[{"id":2261,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2260\/revisions\/2261"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}