jquery操作iframe(齐全版,经IE6&IE6+、firefox、chrome测试通过)
来源:互联网 发布:ug软件是什么软件 编辑:程序博客网 时间:2024/05/16 03:40
- 父窗口获取子窗口元素
- $('@selector', window.frames['@iframeID'].document)
- 子窗口获取父窗口元素
- $('@selector', parent.document)
- 子窗口获取子窗口元素
- $('@selector', parent.window.frames['@iframeID'].document)
- 附注:出于安全考虑,浏览器不允许脚本跨域访问iframe,谷歌浏览器离线状态下认为脚本访问iframe为跨域访问(跟cookie类似,离线状态下不允许使用cookie)
例子如下:
主窗口:(index.html)
- <html>
- <head>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <script type="text/javascript">
- $(function(){
- $('#test-button').click(function(){
- //获取左边iframe的元素(父窗口获取子窗口元素 )
- alert($('#test-button', window.frames['left'].document).text());
- //获取右边iframe的元素(父窗口获取子窗口元素 )
- alert($('#test-button', window.frames['right'].document).text());
- })
- })
- </script>
- </head>
- <body>
- <iframe id="left" width="30%" height="50%" src="left.html"></iframe>
- <iframe id="right" width="30%" height="50%" src="right.html"></iframe>
- <button id="test-button">test-button-in-index</button>
- </body>
- </html>
- <html>
- <head>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <script type="text/javascript">
- $(function(){
- $('#test-button').click(function(){
- //获取主窗口iframe的元素(子窗口获取父窗口元素)
- alert($('#test-button', parent.document).text());
- //获取主窗口右边iframe的元素(子窗口获取子窗口元素)
- alert($('#test-button', parent.window.frames['right'].document).text());
- })
- })
- </script>
- </head>
- <body>
- <button id="test-button">test-button-in-left</button>
- </body>
- </html>
- <html>
- <head></head>
- <body>
- <button id="test-button">test-button-in-right</button>
- </body>
- </html>
0 0
- jquery操作iframe(齐全版,经IE6&IE6+、firefox、chrome测试通过)
- jquery操作iframe(齐全版,经IE6&IE6+、firefox、chrome测试通过)
- 经典代码 iFrame 自适应高度,在IE6/IE7/IE8/Firefox/Opera/Chrome/Safari通过测试。
- iframe自适应高度(IE6、IE7、fireFox下测试通过)
- jquery操作iframe中的HTML 在IE6、Mozilla Firefox 正常
- iframe高度自适应(IE6+、FF、Opera、Chrome等测试通过)
- 写了一个qq表情jquery插件(ie6&ie6+ chrome firefox兼容)
- jqury 使iframe自适应高度(歉容IE6+、fireFox、chrome)
- iframe自适应高度(兼容IE6、IE7、IE8、fireFox、Chrome)
- 利用JQuery实现网页左侧树形菜单(IE6 IE7 Firefox测试通过)
- 七行jquery代码实现图片渐变切换【兼容ie6&IE6+、 Chrome、 Firefox】
- //iframe自适应高度[在IE6 IE7 FF下测试通过]
- javascript跨Iframe遮罩层.(IE6 IE7 IE8 FF测试通过)
- css hack(ie6-9,firefox,chrome,opera,safari)
- css hack(ie6-9,firefox,chrome,opera,safari)
- css hack(ie6-9,firefox,chrome,opera,safari)
- css hack(ie6-9,firefox,chrome,opera,safari)
- Css Hack(ie6-9,firefox,chrome,opera,safari)
- PCA与Whitening
- 【分享】带有转发和情感标签的微博数据
- ACM/ICPC Lost lists uva 10202
- 使用DMV和DMF分析数据库性能
- JSON的应用与解析
- jquery操作iframe(齐全版,经IE6&IE6+、firefox、chrome测试通过)
- mysql5.6.16绿色版配置、运行
- thrift python安装
- socket关闭后无法绑定端口的问题
- 五十七 小知识
- Longest Consecutive Sequence
- linux 下获取所有网卡mac,name
- xPath语法
- HYSBZ 1269 文本编辑器editor(Splay)