<1> js或者jQuery訪问页面中的框架iframe. 

注意:框架内的页面是不能跨域的! 如果有两个页面,在同样域下.

如果:父窗体  index.html ,有id 为 subifrm 的iframe

1. 在index.html运行JS直接訪问子窗体中某元素:

document.getElementById('subifrm').contentWindow.document.getElementById('test').style.color='red'

2. 利用jquery 来訪问子窗体

$("#subifrm").contents().find("#test").css('color','red');

====================================================================

====================================================================

<2> 用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");

====================================================================

====================================================================

<3> 使用jquery操作iframe 

1 页面里有两个ifame

<iframe id="leftiframe"></iframe>

<iframe id="mainiframe></iframe>

<iframe id="leftiframe"></iframe>

<iframe id="mainiframe></iframe>

leftiframe中jQuery改变mainiframe的src代码:

1

$("#mainframe",parent.document.body).attr("src","")

2、 假设内容里面有一个ID为mainiframe的ifame

<iframe id="mainifame"></ifame>

<iframe id="mainifame"></ifame>

ifame包括一个someID

<div id="someID">you want to get this content</div>

<div id="someID">you want to get this content</div>

得到someID的内容

$("#mainiframe").contents().find("someID").html();或者$("#mainiframe").contains().find("someID").text();

$("#mainiframe").contents().find("someID").html();或者$("#mainiframe").contains().find("someID").text();

$("#mainiframe").contents().find("someID").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();

source:

最新文章

  1. UVA 558 判定负环,spfa模板题
  2. Oracle 分组聚合二种写法,listagg和wmsys.wm_concat
  3. HTML,XML中的转义字符
  4. GDB下查看内存命令(x命令)
  5. Bluebird-Core API (三)
  6. 为Eclipse设置背景色
  7. [Codeforces667A]Pouring Rain(数学,几何)
  8. OpenNebula Restfull 接口请求示例
  9. 关于.net中的脚本语言使用
  10. Strategy 模式
  11. C++中模板类使用友元模板函数
  12. hdu 4983 Goffi and GCD(欧拉函数)
  13. 在VirtualBox安装OS X 10.10
  14. linux 标准目录
  15. Java学习笔记——排序算法之希尔排序(Shell Sort)
  16. C#中MessageBox.Show()方法详解
  17. 參与 Spring 4 中文文档翻译
  18. 发布iOS应用时,Xcode报错:Application failed codesign verification.
  19. 意外的php之学习笔记
  20. Vue Element使用icon图标(第三方)

热门文章

  1. JSON Undefined 问题
  2. webdriver高级应用- 使用Chrome浏览器自动将文件下载到指定路径
  3. Apache Log4j 2 is Coming
  4. [linx学习篇] ssh远程服务器免密码
  5. AtCoder Regular Contest 080
  6. 解决面试问题中的top k问题 Leetcode
  7. IO Streams:字符流
  8. SPFA ----模板 O(kE) (k一般不超过2)
  9. Linux Shell系列教程之(十)Shell for循环
  10. 【Luogu】P2447外星千足虫(高斯消元)