1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <html> <body> <iframe id='fra' src="test.html"></iframe> <button onclick="test()">点击</button> <p>一些老的浏览器不支持 iframe。</p> <p>如果得不到支持,iframe 是不可见的。</p> <script> window.onload=function(){ var x = document.getElementById("fra"); let d=x.contentWindow.document; console.log(d); } function test(){ var x = document.getElementById("fra"); let d=x.contentWindow.document; console.log(d.body.innerHTML); } </script> </body> </html> <html> <body> <input value="XXX" onchange="this.defaultValue=this.value"/> <input value="3333" onchange="this.defaultValue=this.value"/> 123132 </body> </html> |
innerHTML下先对input进行重新绑定赋值。
声明: 本文采用 BY-NC-SA 协议进行授权 | WEB开发分享
转载请注明转自《innerHTML无法获取iframe的input更新?》