js 取iframe内的dom, 兼容IE,ff

xiaoxiao2026-03-25  2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <mce:script type="text/javascript"><!-- function f(){ var doc; if (document.all){//IE doc = document.frames["MyIFrame"].document; }else{//Firefox doc = document.getElementById("MyIFrame").contentDocument; } doc.getElementById("s").style.color="blue"; } // --></mce:script> </head> <body οnlοad="f()"> <iframe id = "MyIFrame" name = "MyIFrame" src = "iframePage.asp" width = "100" height="100"></iframe> </body> </html>

相关资源:js中访问html中iframe的文档对象的代码[IE6,IE7,IE8,FF]
转载请注明原文地址: https://www.6miu.com/read-5046247.html

最新回复(0)