拿到iframe中id的值
2014-06-17 11:55
169 查看
</td>
<td><iframe frameBorder='0' width="100%" id="personList" src="<%=basePath%>/main/announce2.0/auditPersonList.jsp "> </iframe></td>
<td>
<table>
auditPersonList.jsp 中有个id='fsName';
取值方法var fsName = $("#personList").contents().find('#fsName').va();
能过调用frame中的方法,取得frame中radio被选中的值
parent.personList.getFsName()
function getFsName(){
var fsName = $("input:[name=fsName]:radio:checked").val();
return fsName;
}
下面简单使用Jquery来操作iframe的一些记录,这个使用纯JS与可以实现。
第一、在iframe中查找父页面元素的方法:
$('#id', window.parent.document)
第二、在父页面中获取iframe中的元素方法:
$(this).contents().find("#suggestBox")
第三、在iframe中调用父页面中定义的方法和变量:
parent.method
parent.value
iframe里用jquery获取父页面body
iframe.html
<html>
<script src='jquerymin.js'>
</script>
<body id='1'>
<div>it is a iframe</div>
</body>
<script>
$(document).ready(
function()
{
var c = $(window.parent.document.body) //麻烦的方法: var c = $($(window).eq(0)[0].parent.document).find('body'); ,忘了可以用前面的方法了
alert(c.html());
}
);
</script>
</html>
content.html
<html>
<script src='jquerymin.js'>
</script>
<body id='fa'>
<iframe src='iframe.html' width='100' height='100'></iframe>
<br>
<br>
<br>
<div id='mydiv'>content iframe</div>
</body>
<script>
function a()
{
alert(1);
}
alert($(document).text());
</script>
</html>
相关文章推荐
- iframe无ID的处理
- Jquery取得iframe中元素的几种方法Javascript Jquery获取Iframe的元素、内容或者ID,反之也行!
- Jquery取得iframe中元素的几种方法Javascript Jquery获取Iframe的元素、内容或者ID,反之也行!
- yii插入一条记录后,拿到id值
- 在Iframe判断ExtJs tree控件选中的节点id并且传输到后台
- Robot Framework之---iframe无id时的定位方法
- Jquery取得iframe中元素的几种方法Javascript Jquery获取Iframe的元素、内容或者ID,反之也行!
- 解决Selenium2Library中的select frame无法选择没有名字,没有id的frame或者iframe的问题
- jQuery基于ID调用指定iframe页面内的方法
- Jquery取得iframe中元素的几种方法Javascript Jquery获取Iframe的元素、内容或者ID
- iframe中的id和name
- 没有id或者name的iframe
- 没有id没有name iframe中获取iframe本身dom元素
- 终于拿到amule的high id了
- jQuery基于ID调用指定iframe页面内的方法
- 在当前iframe中, 获取Iframe的id
- js获取iframe中的元素以及在iframe中获取父级的元素(包括iframe中不存在name和id的情况)
- jQuery基于ID调用指定iframe页面内的方法
- Selenium2Library中select frame关键字对没有name和id的frame或者iframe的处理
- 使用easyUI 从Iframe的页面中拿到主页面的属性值