parent.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
function winOpen(){
window.open('son.html');
//window.close();
}
</script>
</head>
<body>
<form name="f1" method="post" action="">
<input name="username" id="username" value=""/>
<input name="cardnum" id="cardnum" value=""/>
<input type="button" value="button" onclick="winOpen();" />
</form>
</body>
</html>
son.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="JavaScript" type="text/javascript">
/**
*取父页面上的值
*/
function $(str){
var parents=window.opener;//父页面对象
var v= parents.document.getElementById(str);/*还有什么方法得到父页面的表单值?*/
//alert(v);
return v;
}
/**
*取到子面上的对象
*/
function son(str){
var o=document.getElementById(str);
return o;
}
/**
*给子页面设置数据
*/
function sv(s,t){
//alert(s);
if($(t)&&son(s))/*防止页面根本就没有input框*/
son(s).value=$(t).value;
}
/**
*设置
*/
function doSetVal(){
//alert("hello");
sv("username","username");
sv("cardnum","cardnum");
//sv("","");
}
</script>
</head>
<body onload="doSetVal();">
<form name="form1" action="" method="post">
<input type="text" name="username" id="username" value="" />
<input type="text" name="cardnum" id="cardnum" value="" />
</form>
</body>
</html>
分享到:
相关推荐
对window.open进行封装, 使其更好用, 且更兼容, 很多人说window.open不兼容,其实不是, 因为不能直接执行, 必须通过用户手动触发才行;看代码: 代码如下 var openWindow = function(url, options) { var str = ""; ...
如果网页 A 可以发送信息到网页 B,反之也然,而不必动用请求/应答模式,该是一件多么惬意的事儿。可以轻松地实现聊天不是吗?
1> window.showModalDialog()采用JS原理实现,同时父窗口不可操作,window.open()采用新创建一个窗口,同时父窗口可操作; 2> 父窗口与子窗口传递值的方式也有所不同,在子窗口中操作父窗口也语法也不同,分别为var...
2个页面,加了注释,很清晰。
window.opener=null;window.close(),只支持IE6不支持IE7的问题 打开新窗口并且关闭本窗口不弹出要关闭窗口前的提示function openWin(){window.open(‘login.jsp’,”,’fullscreen=yes,menubar=no,resizable=no’);...
支持完整的window.open api 。 为React 16构建(使用ReactDOM.createPortal )。 阻止弹出窗口的处理程序(通过onBlock prop)。 根据父窗口或屏幕使弹出窗口居中。 安装 npm i react-new-window --save 用法 ...
JS代码: window.open(); 而当支付成功后,需要关闭支付平台支付成功界面,并在客户端加载客户端支付成功页面,JS代码: window.opener.location.href=url;window.close();
window.opener,是通过window.open打开子窗体的父窗体的引用。 比如在父窗体parentForm里面,通过window.open(“subForm.html”),那么在subform.html中window.opener就代表parentForm。既然在子窗体中能够拿到父窗体...
本文实例分析了javascript关于open.window子页面执行完成后刷新父页面的方法。分享给大家供大家参考。具体分析如下: 主页面: <input id=btnAdd type=button onclick=openWin(); value=添加 /> 在js中有如下...
window.opener.location.href = window.opener.location.href 刷新以winodw.showModelDialog()方法打开的窗口 window.parent.dialogArguments.document.execCommand('Refresh'); 或 Response.Write("<script>...
代码如下: this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, “window.opener.location.reload();alert(‘销帐成功!’);”, true); 主要是这段js代码:window.opener.location.reload...
Response.Write("<script>window.open('" + Str1 + "','_blank');window.showModalDialog('close.htm');</script>"); close.htm文件 代码为 <body onload="window.parent.opener=null;window.close();"> ...
BOM(Broswer Object Model) 凡是 window 的属性和方法,均可以省略...window.open() 2.在子窗口中使用,表示父窗口的window对象 window.opener window.opener.fatherSayHello(); 调用父窗口的方法 window.opener.a
window.opener=null; window.open(”,’_self’); window.close(); firefox IE7,Opera, chrome,safari Close 3 window.open(”,’_self’); window.close(); firefox IE7,Opera, chrome,sa
方法一: 代码如下: top.window.opener=null; top.window.open(“”,”_self”); top.window.close(); 方法二: 代码如下: top.window.opener = top; top.window.open(”,’_self’,”); top.window.close(); _blank...
例如:A页面通过window.open()方法弹出了B页面,在B页面中就可以通过opener来引用A页面,这样就可以通过这个对象来对A页面进行操作。 3.parentparent用于在iframe,frame中生成的子页面中访问父页面的对象。例如:A...
只要window.opener指向父窗口,就可以访问所有对象. 不仅可以访问值,还可以访问父窗口的方法.值长度无限制. 缺点:两窗口要存在着关系.就是利用window.open打开的窗口.不能跨域. Post.htm <input type=text name=...
[removed] function closeWin(){ window.opener=null; window.open(”,’_self’,”); window.close(); } [removed] <a>logout</a> </body> </html> 火狐默认不支持js关闭浏览器窗口,可以在about:...
熟练掌握window对象的status、location、name、self、opener属性的使用 Window对象是客户端javascript最高层对象之一,只要打开浏览器窗口,不管该窗口中是否有打开的网页,当遇到BODY、FRAMESET或FRAME元素时,...