jQuery操作iframe
来源:互联网 发布:js 长度单位转换 编辑:程序博客网 时间:2024/06/06 20:13
来自:http://weball.blog.sohu.com/97124415.html
只好用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方法
第二种方式
来自:http://www.why100000.com/_articles/show_a_article.asp?autoid=41&tab=tabActionscript
1 内容里有两个ifame
〈iframe id=“leftiframe“...〈/iframe〉
〈iframe id=“mainiframe...〈/iframe〉
leftiframe中jQuery改变mainiframe的src代码:
$(“#mainframe“,parent.document.body).attr(“src“,“http://www.radys.cn“)
2 如果内容里面有一个ID为mainiframe的iframe
〈iframe id=“mainifame“...〉〈/ifame〉
ifame包含一个someID: 〈div id=“someID“〉you want to get this content〈/div〉
得到someID的内容
$(“#mainiframe“).contents().find(“someID“).html() html 或者 $(“#mainiframe“).contains().find(“someID“).text()值
2 如上面所示
leftiframe中的jQuery操作mainiframe的内容someID的内容
$(“#mainframe“,parent.document.body).contents().find(“someID“).html()
或者
$(“#mainframe“,parent.document.body).contents().find(“someID“).val()
- jquery 操作 iframe
- jquery iframe操作
- jQuery操作iframe
- jquery iframe操作
- jquery iframe操作
- jquery iframe操作
- jquery iframe操作
- 使用jquery操作iframe
- jquery iframe操作
- jquery iframe操作
- jquery 操作iframe
- Jquery中操作iframe
- jquery 操作外部iframe
- 使用jquery操作iframe
- jquery操作iframe
- jquery操作iframe
- 使用jquery操作iframe
- jquery iframe操作
- vb.net 中 GridView中数据不刷新问题!~~~
- 【django 学习笔记】07-高级视图和URL配置
- mfc中钩子的使用
- >/dev/null 2>&1
- VS2008安装与部署
- jQuery操作iframe
- WindowsXP不能休眠 - "系统资源不够,无法完成 API"
- Android对话框的显示位置
- Oracle中SQL PLUS的常用指令
- Makefile中变量的替换
- 【django 学习笔记】08-模板高级进阶
- IIS6环境下配置PHP5
- 【django 学习笔记】09-数据模型高级进阶
- 【django 学习笔记】10-通用视图