jQuery操作Frame(iFrame)
没找到很好的方法
只好用DOM方法与jquery方法结合的方式实现了
1.在父窗口中操作 选中IFRAME中的所有单选钮
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");
2.在IFRAME中操作 选中父窗口中的所有单选钮
$(window.parent.document).find("input[@type='radio']").attr("checked","true");
iframe框架的:<iframe src="test.html" id="iframe1" width="700" height="300" frameborder="0" scrolling="auto"></iframe>
IE7中测试通过 回去你自己试试吧
刚才google到的,补充一下
I beat my head against this wall for quite some time.
Try this:
$("#myid", top.document);
the top.document tells the selector to target the myid element which
exists in the topmost document (your parent page). In order for this
to work, jquery must be loaded in the file which is viewed through the
iframe.
我的代码
$('#parentElem', top.document).append('<div class="imgbox" id="imgbox"><img class="img" src="pp.png" id="img"></div>');
1.在父窗口中操作 选中IFRAME中的所有单选钮
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");
那选择id自然就是依然使用find方法
$(window.frames["iframe1"].document).find("#id")
实际楼上上的方法本质上在Jq内部也是调用了find方法
子窗体:opener;(window.opener.reload();)
上面的都是网上摘的,下面补充很重要的一点:
你可能已经注意到了,上面提及的都是自上而下的selector方法,也就是从上级window查找下级window(包括iframe创建的window),如果我们希望从下级window,比如希望通过iframe中的window找到iframe的parentNode,可以这样:
var parentFrame=null;
if(window!=window.top){parentFrame=window.frameElement.name};
往下就可以直接$(.....
当然,一个topwindow中仅仅包含一个iframe时我们没有必要这样,但当若干iframe存在时,这个方法还是很有用的。
jQuery操作Frame(iFrame)的更多相关文章
- Jquery 操作IFrame
使用jquery操作iframe 1. 内容里有两个ifame <iframe id="leftiframe"...</iframe> <iframe id ...
- jquery 操作iframe的几种方法总结
iframe在复合文档中经常用到,利用jquery操作iframe可以大幅提高效率,这里收集一些基本操作 DOM方法: 父窗口操作IFRAME:window.frames["iframeSo ...
- 使用jquery操作iframe
1. 内容里有两个ifame <iframe id="leftiframe"...</iframe> <iframe id="mainiframe ...
- 原生js与jquery操作iframe
1 原生js获取iframe的window对象 //方法1 document.getElementById('iframeId').contentWindow; //方法2 window.frame ...
- jquery操作iframe中的js函数
关键字:jquery操作iframe中的js函数 1.jquery操作iframe中的元素(2种方式) var tha = $(window.frames["core_content&quo ...
- jquery操作iframe
query取得iframe中元素的几种方法 在iframe子页面获取父页面元素 代码如下: $('#objId', parent.document); // 搞定... 在父页面 获取iframe子页 ...
- JQuery操作iframe父页面与子页面的元素与方法
JQuery操作iframe父页面与子页面的元素与方法 JQUERY IFRAME 下面简单使用Jquery来操作iframe的一些记录,这个使用纯JS也可以实现. 第一.在iframe中查找父页面元 ...
- jquery操作iframe的方法:父页面和子页面相互操作的方法
今天在弄jquery操作iframe中元素:先由iframe中的子页面b.html给外面的父页面a.html页面传值,再将a.html页面计算机的值放到b.html页面上,这里就用到子页面和父页面相互 ...
- jQuery操作iframe中js函数的方法小结
1.jquery操作iframe中的元素(2种方式) ? 1 2 var tha = $(window.frames["core_content"].document).find( ...
随机推荐
- 分类器评估方法:ROC曲线
注:本文是人工智能研究网的学习笔记 ROC是什么 二元分类器(binary classifier)的分类结果 ROC空间 最好的预测模型在左上角,代表100%的灵敏度和0%的虚警率,被称为完美分类器. ...
- 如何用dat批处理文件关闭某端口对应程序-Windows自动化命令
如何用dat批处理文件关闭某端口对应程序? 网上找到的大部分都是手动操作,第一步先查出端口,第二步在根据上一步查到的端口手动去关闭进程.但我的需求不是这样的,我需要全自动处理.用于 dubbo 服务进 ...
- 【BZOJ-2888】资源运输 LCT + 启发式合并
2888: 资源运输 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 63 Solved: 33[Submit][Status][Discuss] D ...
- Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem F. Turning Grille 暴力
Problem F. Turning Grille 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c70 ...
- Mysql_解决The total number of locks exceeds the lock table size错误
在操作mysql数据库表时出现以下错误. 网上google搜索相关问题,发现一位外国牛人这么解释: If you're running an operation on a large number o ...
- 在Win7中用ftp的方法
我的电脑是Win7 32位操作系统,之前一直没有成功使用过ftp 之初以为是ftp客户端的问题,换了几个软件都不行,然后换我的一台vps服务器(win2003)连接同一个ftp服务器可以正常连接使用 ...
- STM32学习日志--使用DMA功能自动更新PWM的输出
/******************************************************************************* 编译环境: EWARM V5.30 硬 ...
- ARM 非对齐的数据访问操作
I’m confused about unaligned memory accesses on ARM. My understanding was that they’re not allowed — ...
- 理解 process.initgroups(user, extra_group)
这个函数是对 linux C函数 initgroups() 的包装 node.js 官方文档非常含糊,还是看 linux C函数文档的解释!非常清楚明确. The initgroups() fun ...
- 利用/proc/pid/pagemap将虚拟地址转换为物理地址
内核文档: Documentation/vm/pagemap.txt pagemap is a new (as of 2.6.25) set of interfaces in the kernel t ...