兼容IE和Firefox的Javascript访问Iframe的代码

6504阅读 1评论2010-09-12 dbconf
分类:系统运维

1.取得iframe对象用:

 document.getElementById("iframeId")

2.取得iframe里的页面的window对象用:

 document.getElementById("iframeId").contentWindow

或是

window.frames["iframeName"]

3.取得iframe里的页面的docuemnt对象用:

 document.getElementById("iframeId").contentWindow.document

或是

window.frames["iframeName"].document

4.访问iframe里的页面中的对象用:

 document.getElementById("iframeId").contentWindow.document.getElementById("objId")

或是

window.frames["iframeName"].document.getElementById("objId")

5.访问iframe里的页面中的javascript代码用:

 document.getElementById("iframeId").contentWindow.functionName()

或是

window.frames["iframeName"].functionName()

 

总结:

访问页面里的对象通过document对象.

访问页面里的javascript通过window对象.

上一篇:linux环境sqlplus中使用backspace键出现乱码的解决方法zz
下一篇: js如何输出一个多行的变量

文章评论