js获取iframe对象

搜索资料获取iframe对象可以这样写

document.frames("iframeId").document;

或

 window.frames['iframeId'].document

注:注意:window.frames只可写成window.frames[‘iframeId’]不能写成window.frames(‘iframeId’)
但是在IE环境下测试会报Uncaught TypeError: document.frames is not a function 这样的错

是用下面的写法解决该问题的:(可以支持在IE10、IE11和google环境下使用)

document.getElementById("iframeId").contentDocument;

你可能感兴趣的:(IE兼容)