window.parent 与 window.opener
window.parent针对iframe,window.opener针对window.open
父页面parent.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<script type="text/javascript">
function openSubWin()
{
var _width = 300 ;
var _height = 200 ;
var _left = (screen.width - _width) / 2 ;
var _top = (screen.height - _height) / 2 ;
window.open("third.jsp",null,
"height=" + _height + ",width=" + _width + ",status=no,toolbar=no,menubar=no,location=no,resizable=yes,left=" + _left + ",top=" + _top);
}
</script> <body>
<form name="form1"> name:<input type="text" name="username" id="username" value="haohao" />
<input type="button" value="弹出子页面" onClick="openSubWin();"> </form>
<hr/>
<div>
<iframe src="child.jsp"></iframe>
</div> </body>
</html>
子页面child.jsp:
<script type="text/javascript"> function fun(){
alert(window.parent.document.getElementById("username").value);
window.parent.document.getElementById("username").value="来自子页面的数据";
}
</script>
</head>
<body>
<p style="color:red;">子页面</p>
<input type="button" value="dianji" onclick="fun()"/>
运行后界面:
点击子页面按钮“dianji” :
页面third.jsp:
<script type="text/javascript">
function UpdateParent()
{
var _parentWin = window.opener ;
_parentWin.form1.username.value = "来自子窗口 的参数" ;
}
</script>
<input type="button" name="button" id="button" value="更新主页面的UserName内容" onClick="UpdateParent();">
点击按钮“更新主页面的UserName内容”改变parent.jsp页面的值
window.opener是当前页面A通过open方法弹出一个窗口B,那在B页面上 window.opener就是A
window.parent是当前页面C通过location.href转到新的页面D,那在D页面上window.parent就是C
或者是页面E里套一个frame为F,那F页面的window.parent就是E
如何页面A里套一个frame为B,B页面有个按钮,点击open一个页面C,那么在C页面window.opener.parent就是A
window.parent 与 window.opener的更多相关文章
- JavaScript中,window.opener是什么?window.parent和window.opener有啥区别?
来自CSDN的问答: window.opener是什么啊? ++++++++++++++++++++++++++++++++++++++++++++++++++ 弹出本窗体的句柄 比如你想点一个按钮直 ...
- window.parent与window.opener的区别
有这样一个需求,弹出一个新窗口 并从该新页面的select选择框中选择需要的类别,再返回到之前的父窗口页面的某个文本框中.这里就要用到window.parent和window.opener 如题两种方 ...
- (转)window.parent和window.opener区别
下面一段代码是关于window.parent和window.opener区别 来讲的,我们如果要用到iframe的值传到另一框架就要用到window.opener.document.getElemen ...
- window.parent与window.openner区别介绍
今天总结一下js中几个对象的区别和用法: 首先来说说 parent.window与top.window的用法 "window.location.href"."locati ...
- window.parent与window.openner
window.parent与window.openner区别介绍 作者: 字体:[增加 减小] 类型:转载 今天总结一下js中几个对象的区别和用法,对这几个概念混淆的朋友可以看看 今天总结一下js中几 ...
- window.parent与window.opener的区别与使用
window.parent 是iframe页面调用父页面对象 举例: a.html 如果我们需要在b.html中要对a.html中的username文本框赋值(就如很多上传功能,上传功能页在ifrma ...
- window.parent与window.opener、window.showModalDialog的区别 opener和showModalDialog刷新父页面的方法
项目中使用案例: 父窗体 <s:form namespace="/forexagent" id="listSearchForm" name="t ...
- window.parent与window.openner 之前的总结
今天总结一下js中几个对象的区别和用法: 1.首先来说说 parent.window与top.window的用法 "window.location.href","loca ...
- window.parent 与 Window.top
window.parent 返回当前窗口的父窗口对象. 如果一个窗口没有父窗口,则它的 parent 属性为自身的引用. 如果当前窗口是一个 <iframe>, <object> ...
随机推荐
- [译]bare repository
git init --bare 使用--bare创建的repository没有工作目录, 在这个repository中不能修改文件和commit. 中心repository必须是bare reposi ...
- 第二章平稳时间序列模型——ACF和PACF和样本ACF/PACF
自相关函数/自相关曲线ACF AR(1)模型的ACF: 模型为: 当其满足平稳的必要条件|a1|<1时(所以说,自相关系数是在平稳条件下求得的): y(t)和y(t-s)的 ...
- 使用xp光盘修复系统的方法步骤
对于使用Windows XP系统的朋友来说,当系统出现崩溃或者系统使用时出现一些莫名其妙的错误时,你采用什么方法解决呢?一般都是采用重装系统或者使用Ghost恢复等. 但是使用这些方法各有缺陷,比如重 ...
- 使用Carthage安装第三方Swift库
http://blog.crazyphper.com/?p=3661 carthage update
- C语言各种标准的
[K&R C] 1978 年,Dennis Ritchie 和 Brian Kernighan 合作推出了<The C Programming Language>的第一版(按照惯例 ...
- tomcat 虚拟节点
<Context path=”Welcome” docBase=”c:\hello\hello” reloadable=”true” /> contex指上下文,实际上就是一个web项目: ...
- win7平台下React-Native Android:Unable to upload some APKs
一.问题描述 根据网络上的Win7平台下React-native配置教程配置好开发环境的过程中,在艰难进行到react-native run-android这一步时,发现一直出现错误,截图如下: 错误 ...
- python spark 配置
前提:已经装好 java 1.8 和 hadoop 2.7 1. 下载解压放后的目录 /Users/gao/spark-1.4.1-bin-hadoop2.6 2. 在~/.bash_profile ...
- [codevs1022]覆盖
[codevs1022]覆盖 试题描述 有一个N×M的单位方格中,其中有些方格是水塘,其他方格是陆地.如果要用1×2的矩阵区覆盖(覆盖过程不容许有任何部分重叠)这个陆地,那么最多可以覆盖多少陆地面积. ...
- 回复《我要阻止做java开发的男朋友去创业型公司工作吗?》园友问题
真的非常开心能收到这么多园友的关心,看到这么多的回复顿感身边处处充满爱.也非常感谢大家踊跃的帮我出谋划策,小女子在此有礼了! 我先来回答一下性别的问题(前面已经暴露了……),我是前端程序媛.大三时和男 ...