contentWindow 和contentDocument区别 及iframe访问
来源:互联网 发布:js禁止浏览器刷新按钮 编辑:程序博客网 时间:2024/05/21 10:59
a>contentWindow 兼容各个浏览器,可取得子窗口的 window 对象。b>contentDocument Firefox 支持,> ie8 的ie支持。可取得子窗口的 document 对象。兼容获取document对象:var getIFrameDoc = function(){var iobj = document.createElement("iframe");document.getElementsByTagName("body")[0].appendChild(iobj);return iobj.contentDocument || iobj.contentWindow.document;}基本使用:1)document.getElementById("myiframe").contentWindow 得到iframe对象后,就可以通过contentWindow得到iframe包含页面的window对象,然后就可以正常访问页面元素了;2)$("#myiframe")[0].contentWindow jquery选择器获得iframe,先把jquery对象转换为DOM对象,或者使用get()方法转换;3)$("#myiframe")[0].contentWindow.$("#dd").val() 可以在得到iframe的window对象后接着使用jquery选择器进行页面操作;4)$("#myiframe")[0].contentWindow.username="zhangsan"; 可以通过这种方式向iframe页面传递参数,在iframe页面window.username就可以获取到值,username是自定义的全局变量;5)在iframe页面通过parent可以获得主页面的window,接着就可以正常访问父亲页面的元素了;7)parent.$("#frame_A")[0].contentWindow.document.getElmentById("#frame_B"); 同级iframe页面之间调用,需要先得到父亲的window,然后调用同级的iframe得到window进行操作;
- contentWindow 和contentDocument区别 及iframe访问
- IFRAMEs, .contentWindow, .contentDocument区别
- 关于iframe中的contentWindow, contentDocument
- contentWindow 和 contentDocument
- 各浏览器Iframe对contentWindow、contentDocument、document及frames属性测试
- 各浏览器Iframe对contentWindow、contentDocument、document及frames属性测试
- JS操作iframe里的DOM || contentWindow,contentDocument
- 关于 contentWindow, contentDocument
- 关于 contentWindow, contentDocument
- 关于 contentWindow, contentDocument
- 关于 contentWindow, contentDocument
- contentwindow & contentdocument
- contentwindow 和contentdocument dom对象和jquery对象
- iframe.contentWindow
- iframe的 contentWindow属性
- iframe的contentWindow属性
- iframe.contentWindow 介绍
- iframe.contentWindow 介绍
- 大数据量-数据库优化
- 除了管道和重定向,还有命令行参数
- stm32f103vet6的学习
- Lucene核心--构建Lucene搜索(上篇,理论篇)
- s3c2440系统时钟
- contentWindow 和contentDocument区别 及iframe访问
- 顶礼南师 感恩南师 追随南师
- javaScript 扩展(prototype)
- CI9.2-字符串排序
- 顺序表删除和X相同的所有元素(C)
- MATLAB像素颜色的表达方式
- 推荐近年来印象最深的几本书 .
- 使用Excel背单词-高效-简单
- spring MVC session传递model