document.frames('') 不兼容IE高版本问题

 

W3C的标准告诉我们,可以通过Dom对象的contentDocument属性来返回文档对象。IE8开始支持,如果你的项目不用兼容IE6,IE7的话使用这种方式最好。

document.getElementById('myf').contentWindow.document //在ie与谷歌都行

    IE6,IE7需要如此访问

 document.frames('myf').document//ie中可以

   兼容方式: 

 var doc = document.getElementById('myf' ).contentDocument || document.frames['myf'].document;

  使用Jquery则简单些:

 $("myf").contents().find("selector");
 $(window.frames["myf"].document).find("#selector")

 

var doc = window.frames["myf"]. contentDocument || window.frames["myf"]. contentWindow.document;

 获取iframe页面的方法(engineList.jsp)

var creatorInfo=document.getElementById("myf").contentWindow.getCheckedAliyunid();

 问题:

  document.frames只有IE、Opera浏览器支持,等同于window.frames,用来获取window对象的集合。而在Firefox、Chrome、Safari浏览器中使用document.frames不能获取到Frame元素。

  解决:用window.frames[]代替document.frames()或document.frames[]

(window.frames只可写成window.frames['myf']不能写window.frames('myf'))

你可能感兴趣的:(asp及js)