兼容IE和Firefox的Javascript访问Iframe的代码
时间: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对象.