在iframe中获取父页面的元素
a.html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div id="a">hello world!!!</div>
<div id="b">
<iframe id="frm" name="frm" src="b.html"></iframe>
</div>
</body>
</html>
b.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery.js" ></script>
<script type="text/javascript">
function aa(){
//获取本页面的元素
//var a = document.getElementById("a12").innerHTML;
//获取父页面的元素
//方法一
//var a = $(window.parent.document).find("#a").text();
//方法二
var a = $("#a",window.parent.document).text();
alert(a);
}
</script>
</head>
<body>
<div id="a12">哈哈</div>
<div>
<div id="btn" onclick="aa()">点击</div>
</div>
</body>
</html>
在iframe中获取父页面的元素的更多相关文章
- Js/Jquery获取iframe中的元素 在Iframe中获取父窗体的元素方法
在web开发中,经常会用到iframe,难免会碰到需要在父窗口中使用iframe中的元素.或者在iframe框架中使用父窗口的元素 js 在父窗口中获取iframe中的元素 1. 格式:window ...
- js获取iframe中的元素以及在iframe中获取父级的元素(包括iframe中不存在name和id的情况)
第一种情况:iframe中不存在name和id的方法:(通过contentWindow获取) var iframe = document.getElementsByTagName('iframe' ...
- iframe中操作主体页面的元素,方法
在不使用三大框架的情况下,iframe的使用可以做到在页面中直接引入别的页面作为当前页面的一部分,但是在iframe的使用过程中存在一些相互之间的操作 例如在iframe中获取主页面的元素,使用主页面 ...
- javascript获取iframe框架中页面document对象,获取子页面里面的内容,iframe获取父页面的元素,
javascript获取iframe框架中,加载的页面document对象 因为浏览器安全限制,对跨域访问的页面,其document对象无法读取.设置属性 function getDocument(i ...
- iframe 子页面获取父页面的元素并且控制样式
父页面的代码 <div id="div5" style="position:relative;height:500px;"> ...
- iframe子页面获取父页面元素的方法
在iframe子页面获取父页面元素 代码如下: $.('#objld', parent.document); 在父页面获取iframe子页面的元素 代码如下: $("#objid" ...
- 在iframe窗体内 获取父级的元素;;在父窗口中获取iframe中的元素
在iframe中获取父窗口的元素 $(‘#父窗口中的元素ID’, parent.document).click(); 在父窗口中获取iframe中的元素 $(“#iframe的ID”).content ...
- javascript 获取父页面中元素对象方法
父页面中: <input type="hidden" id="areaID" value="test1"> <iframe ...
- iframe子页面获取父页面元素和window对象
项目中发现要在iframe的弹框中获取父页面中的元素,我们可以按照如下代码操作:$(window.parent.document).find('selector').attr('XXX') 如果我们需 ...
随机推荐
- Hibernate java.lang.NoSuchFieldError: INSTANCE
在使用hibernate3.6.2是我遇到了一个有趣的错误java.lang.NoSuchFieldError: INSTANCEat org.hibernate.type.BasicTypeRegi ...
- C#如何获取真实IP地址
大家获取用户IP地址常用的方法是 C# 代码 复制 string IpAddress = ""; if((HttpContext.Current.Request.Serve ...
- 解决easyui和bootstrap兼容问题
在使用bootstrap和easyui的时候,发现很多有冲突的地方,包括datagrid控件和combo等,以下进行的问题修正,保证easyui正常显示 /*bootstrap兼容问题和easyui的 ...
- Lua中实现队列(高效方式)
转自http://www.cnblogs.com/stephen-liu74/archive/2012/06/25/2417894.html 在Lua中实现队列的简单方法是使用table库函数inse ...
- Red5 1.0.5安装过程记录
Red5从旧的服务器切换到了github上后,截至20150702仍未更新文档.为了搭建Red5开发环境,我像无头苍蝇一样乱转了很多博客和StackOverflow.藉此记录这次安装过程,希望能够帮助 ...
- shell脚本应用(5)--实用脚本片段
校验参数 if [ "$#" -ne 1 ] then echo "Incorrect number of arguments" echo "Usag ...
- guslterFS
Installing GlusterFS - a Quick Start Guide Purpose of this document This document is intended to giv ...
- HDU4349--Xiao Ming's Hope(数论)
输入一个n(1<=n<=108),求C(n,0),C(n,1),C(n,2)...C(n,n)有多少个奇数. Lacus定理 http://blog.csdn.net/acm_cxlove ...
- PHP使用IP地址连接MySQL数据库
我们通常测试的时候都是用mysql_connect("localhost","usrname","password");的方式来连接MySQ ...
- AS3 IOC框架Spring Actionscript 的使用总结
Spring Actionscript 是众多围绕依赖注入提供解决方案的Flex控制反转框架之一 AS3 下经典的IOC框架有Spring ActionScript.Parsley.Flicc和Swi ...