兼容IE和Firefox的javascript获取iframe文档内容的变量

来源:互联网 发布:小学生预防网络诈骗 编辑:程序博客网 时间:2024/05/21 10:12

document.frameId.varName;在谷歌和ie中正常显示,但是在火狐中会出错,TypeError: document.frameId is undefined

解决方法:document.getElementById("frameId").contentWindow.varName;


ie&firefox  

      document.getElementById("frameId").contentWindow.varName; 
      document.getElementById(" frameId ").contentWindow.functionName(); 
      document.getElementById(" frameId ").contentWindow.document.getElementById("someId"); 
      $("# frameId ").contents().find("# someId "); 


  ie  
      document.frames(" frameId ").window.document.getElementById(" someId "); 


  firefox  
      document.getElementById(" frameId ").contentDocument.getElementById(" someId ");
原创粉丝点击