{"id":2020,"date":"2024-11-10T11:40:53","date_gmt":"2024-11-10T03:40:53","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2020\/"},"modified":"2024-11-10T11:40:53","modified_gmt":"2024-11-10T03:40:53","slug":"%e5%a6%82%e4%bd%95%e4%bb%8e%e5%a4%96%e5%b1%82-iframe-%e8%8e%b7%e5%8f%96%e5%b5%8c%e5%a5%97-iframe-%e4%b8%ad%e7%9a%84%e5%85%83%e7%b4%a0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2020\/","title":{"rendered":"\u5982\u4f55\u4ece\u5916\u5c42 iframe \u83b7\u53d6\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173063072385781.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4ece\u5916\u5c42 iframe \u83b7\u53d6\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4ece\u5916\u5c42 iframe \u83b7\u53d6\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728 iframe \u5185\u83b7\u53d6\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20<\/strong><\/p>\n<p>\u5982\u679c\u9700\u8981\u4ece\u5916\u5c42 iframe \u4e2d\u83b7\u53d6\u5d4c\u5957 iframe \u5185\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p>\u9996\u5148\uff0c\u627e\u5230\u5916\u5c42 iframe \u7684\u7a97\u53e3\u5bf9\u8c61\uff0c\u7136\u540e\u5229\u7528 window.frames[&#8220;iframename&#8221;].document \u8bbf\u95ee\u5d4c\u5957 iframe \u7684\u6587\u6863\u5bf9\u8c61\u3002<\/p>\n<pre>const outeriframe = document.getelementbyid(\"outeriframe\");\nconst nestediframedocument = window.frames[\"nestediframename\"].document;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u63a5\u7740\uff0c\u53ef\u4ee5\u4f7f\u7528 jquery \u6216\u539f\u751f javascript \u65b9\u6cd5\u5728\u5d4c\u5957 iframe \u6587\u6863\u5bf9\u8c61\u4e2d\u5bfb\u627e\u6240\u9700\u7684\u5143\u7d20\u3002<\/p>\n<p><strong>jquery \u65b9\u6cd5\uff1a<\/strong><\/p>\n<pre>$(window.frames[\"nestediframename\"].document).find(\"#inputid\");<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u539f\u751f javascript \u65b9\u6cd5\uff1a<\/strong><\/p>\n<pre>nestedIframeDocument.getElementById(\"inputId\");<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u5c31\u53ef\u4ee5\u83b7\u53d6\u5230\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4ece\u5916\u5c42 iframe \u83b7\u53d6\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 iframe \u5185\u83b7\u53d6\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20 \u5982\u679c\u9700\u8981\u4ece\u5916\u5c42 iframe \u4e2d\u83b7\u53d6\u5d4c\u5957 iframe \u5185\u7684\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u9996\u5148\uff0c\u627e\u5230\u5916\u5c42 iframe \u7684\u7a97\u53e3\u5bf9\u8c61\uff0c\u7136\u540e\u5229\u7528 window.frames[&#8220;iframename&#8221;].document \u8bbf\u95ee\u5d4c\u5957 iframe \u7684\u6587\u6863\u5bf9\u8c61\u3002 const outeriframe = document.getelementbyid(&#8220;outeriframe&#8221;); const nestediframedocument = window.frames[&#8220;nestediframename&#8221;].document; \u767b\u5f55\u540e\u590d\u5236 \u63a5\u7740\uff0c\u53ef\u4ee5\u4f7f\u7528 jquery \u6216\u539f\u751f javascript \u65b9\u6cd5\u5728\u5d4c\u5957 iframe \u6587\u6863\u5bf9\u8c61\u4e2d\u5bfb\u627e\u6240\u9700\u7684\u5143\u7d20\u3002 jquery \u65b9\u6cd5\uff1a $(window.frames[&#8220;nestediframename&#8221;].document).find(&#8220;#inputid&#8221;); \u767b\u5f55\u540e\u590d\u5236 \u539f\u751f javascript \u65b9\u6cd5\uff1a nestedIframeDocument.getElementById(&#8220;inputId&#8221;); \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0c\u5c31\u53ef\u4ee5\u83b7\u53d6\u5230\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20\u4e86\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4ece\u5916\u5c42 iframe \u83b7\u53d6\u5d4c\u5957 iframe \u4e2d\u7684\u5143\u7d20\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2020","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=2020"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2020\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}