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;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章