opener 、self、parent
来源:互联网 发布:深圳市网络预约出租车 编辑:程序博客网 时间:2024/04/30 07:18
1: window.parent 是iframe页面调用父页面对象 举例: a.html <html> <head><title>父页面</title></head> <body> <form name="form1" id="form1"> <input type="text" name="username" id="username"/> </form> <iframe src="b.html" width=100%></iframe> </body> </html> 如果我们需要在b.htm中要对a.htm中的username文本框赋值,就如很多上传功能,上传功能页在Ifrmae中,上传成功后把上传后的路径放入父页面的文本框中 我们应该在b.html中写 <script type="text/javascript"> var _parentWin = window.parent ; _parentWin.form1.username.value = "xxxx" ; </script> 2: window.opener 是window.open 打开的子页面调用父页面对象 opener:对打开当前窗口的window对象的引用,如果当前窗口被用户打开,则它的值为null. self:自引用属性,是对当前window对象的应用,与window属性同义. self代表自身窗口,opener代表打开自身的那个窗口,比如窗口A打开窗口B.如果靠window.open方法,则对于窗口B,self代表B自己,而opener代表窗口A. |
-------------------------------------------------------------------------------------------------
1、window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一个链接而打开了b.htm,然后打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以写为:
window.opener.document.getElementById("name").value = "输入的数据";
2、self 指当前窗口;
3、parent 的意思是本窗口的父窗口,也就是说通过哪个窗口打开了本窗口,哪个窗口就是本窗口的 parent;
4、document.all 是文档中所有标签组成的一个数组变量,包括了文档对象中所有元素
5、top 代表打开的顶层窗口
a href="" target="_blank">來打開应该是parent,opener用与用脚本创建的窗口,最常见的就是网页对话框
-----------------------------------------------------------------------------------------------------------
opener即谁打开我的,比如A页面利用window.open弹出了B页面窗口,那么A页面所在窗口就是B页面的
opener,在B页面通过opener对象可以访问A页面。
parent表示父窗口,比如一个A页面利用iframe或frame调用B页面,那么A页面所在窗口就是B页面的
parent。
在JS中,window.opener只是对弹出窗口的母窗口的一个引用。比如:
a.html中,通过点击按钮等方式window.open出一个新的窗口b.html。那么在b.html中,就可以通过
window.opener(省略写为opener)来引用a.html,包括a.html的document等对象,操作a.html的内容。
假如这个引用失败,那么将返回null。所以在调用opener的对象前,要先判断对象是否为null,否则会
出现“对象为空或者不存在”的JS错误。
<html>
<body>
<form. name=form1>
<input type=text name=inpu >
<input type=button >
</form>
</body>
</html>
--------------------------------
back2opener.html
--------------------------------
<html>
<body>
<form. name=form1>
<input type=text name=inpu >
<a class=under href=# >添加</a>
</form>
</body>
</html>
window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一个链接而打开了
b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以
写为:
window.opener.document.getElementById("name").value = "输入的数据";
-----------------------------------------------------------------------------------------------------
1:
举例:
a.html
<html>
<head><title>父页面</title></head>
<body>
<form name="form1" id="form1">
<input type="text" name="username" id="username"/>
</form>
<iframe src="b.html" width=100%></iframe>
</body>
</html>
如果我们需要在b.htm中要对a.htm中的username文本框赋值,就如很多上传功能,上传功能页在Ifrmae中,上传成功后把上传后的路径放入父页面的文本框中
我们应该在b.html中写
<script type="text/javascript">
var _parentWin = window.parent ;
_parentWin.form1.username.value = "xxxx" ;
</script>
实例地址:
源码:
1.a
<html>
<head><title>主页面</title></head>
<body>
<form name="form1" id="form1">
<iframe src="b.html" width=100%></iframe>
</body>
</html>
1.b
<html>
<head><title></title>
<script type="text/javascript">
{
var _parentWin = window.parent ;
_parentWin.form1.username.value = "xxxx" ;
}
</script>
</head>
<body>
<form name="form1" id="form1">
<p> </p>
<p align="center">
</p>
<p> </p>
</form>
</html>
2:
实例地址:
源码:
2.a
<html>
<head>
<title>主页面</title>
<script type="text/javascript">
function openSubWin()
{
var _height = 200 ;
var _top = (screen.height - _height) / 2 ;
window.open("b.html",null,
"height=" + _height + ",width=" + _width + ",status=no,toolbar=no,menubar=no,location=no,resizable=yes,left=" + _left + ",top=" + _top);
}
</script>
</head>
<body>
</html>
2.b
<html>
<head>
<title>子页面</title>
<script type="text/javascript">
{
var _parentWin = window.opener ;
_parentWin.form1.username.value = "xxxx" ;
}
</script>
</head>
<body>
<form name="form1" id="form1">
<p> </p>
<p align="center">
</p>
<p> </p>
</form>
</body>
</html>
<%
Call FunMsg("upload_pic.asp?Send=OK&FileName="&SFileName&"&FileName_small="&Sfilename_small,"文件上传成功!")
Dim Send,StrBody
Send=Request.QueryString("Send")
FileName=Request.QueryString("FileName")
FileName_small=request.QueryString("FileName_small")
if Send="OK" And FileName<>"" And FileName_small<>"" then
StrBody="onLoad=setOpener('"&FileName&"','"&FileName_small&"')"
end if
<script type="text/javascript">
function setOpener(index,index_small) {
}
</script>
<body leftmargin="0" topmargin="0" <%=StrBody%>>
<script type="text/javascript">
function Images(catName,catName_small){
document.form.P_Pic.value=catName;
document.form.P_smallPic.value=catName_small;
document.form.P_PicB.src="../info/Pic/"+catName;
}
</script>
---------------------------------------------------------------------------------------------
- opener 、self、parent
- js opener,self,parent 区别
- js opener,self,parent 区别
- JS的parent、opener、self对象
- JS的parent、opener、self对象
- js中, opener,self,parent 区别
- 关于Opener,parent,top,self等窗体属性的研究
- 关于Opener,parent,top,self等窗体属性的研究
- 代表窗口的self,opener,parent的区别
- js中window.parent和window.opener,window.self、window.top用法
- 重走JAVA编程路:Js中self,top,parent,opener详解,傻傻分不清楚
- window.opener ,window.parent
- parent.window.opener.location
- parent 、opener对比
- opener与parent
- top,parent,opener,iframe
- window.parent & window.opener
- window.parent & window.opener
- 将XML转换成HTML格式
- 查看当前数据库中没用的索引(sys.dm_db_index_usage_stats)
- VC 导出的格式 Excel
- csdn博客开通
- Windows线程同步方法
- opener 、self、parent
- 通过oracle events查找Ora-00942问题
- ASP.NET 弹出对话框和页面之间传递值的经验总结
- 多个存储过程中的事物问题
- 项目管理者的尴尬
- (2)Silverlight开发工具Microsoft Expression Blend 2 之“左侧ToolBox”
- FckEditor中文配置手册详细说明
- 毕业两年才知道(转)
- 解决 SQL SERVER 企业管理器 MMC 无法创建管理单元