`
ileson
  • 浏览: 210536 次
  • 性别: Icon_minigender_1
  • 来自: 河南省
社区版块
存档分类
最新评论

window.open & opener

    博客分类:
  • RIA
阅读更多
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>

分享到:
评论

相关推荐

    Javascript中封装window.open解决不兼容问题

    对window.open进行封装, 使其更好用, 且更兼容, 很多人说window.open不兼容,其实不是, 因为不能直接执行, 必须通过用户手动触发才行;看代码: 代码如下 var openWindow = function(url, options) { var str = ""; ...

    用window.open,opener实现网页间通信

    如果网页 A 可以发送信息到网页 B,反之也然,而不必动用请求/应答模式,该是一件多么惬意的事儿。可以轻松地实现聊天不是吗?

    showModalDialog open弹出子窗口操作parent、opener父窗口及跨域处理

    1&gt; window.showModalDialog()采用JS原理实现,同时父窗口不可操作,window.open()采用新创建一个窗口,同时父窗口可操作; 2&gt; 父窗口与子窗口传递值的方式也有所不同,在子窗口中操作父窗口也语法也不同,分别为var...

    字符串 window.open() window.opener window.name window对象等的总结

    2个页面,加了注释,很清晰。

    解决window.opener=null;window.close(),只支持IE6不支持IE7,IE8的问题

    window.opener=null;window.close(),只支持IE6不支持IE7的问题 打开新窗口并且关闭本窗口不弹出要关闭窗口前的提示function openWin(){window.open(‘login.jsp’,”,’fullscreen=yes,menubar=no,resizable=no’);...

    react-new-window:using使用`window.open`在React中弹出新窗口

    支持完整的window.open api 。 为React 16构建(使用ReactDOM.createPortal )。 阻止弹出窗口的处理程序(通过onBlock prop)。 根据父窗口或屏幕使弹出窗口居中。 安装 npm i react-new-window --save 用法 ...

    JS window.opener返回父页面的应用

    JS代码: window.open(); 而当支付成功后,需要关闭支付平台支付成功界面,并在客户端加载客户端支付成功页面,JS代码: window.opener.location.href=url;window.close();

    window.opener用法和用途实例介绍

    window.opener,是通过window.open打开子窗体的父窗体的引用。 比如在父窗体parentForm里面,通过window.open(“subForm.html”),那么在subform.html中window.opener就代表parentForm。既然在子窗体中能够拿到父窗体...

    javascript关于open.window子页面执行完成后刷新父页面的问题分析

    本文实例分析了javascript关于open.window子页面执行完成后刷新父页面的方法。分享给大家供大家参考。具体分析如下: 主页面: &lt;input id=btnAdd type=button onclick=openWin(); value=添加 /&gt; 在js中有如下...

    jsp 刷新父页面

    window.opener.location.href = window.opener.location.href 刷新以winodw.showModelDialog()方法打开的窗口 window.parent.dialogArguments.document.execCommand('Refresh'); 或 Response.Write("&lt;script&gt;...

    window.open的页面如何刷新(父页面)上层页面

    代码如下: this.ClientScript.RegisterStartupScript(this.GetType(), this.Title, “window.opener.location.reload();alert&#40;‘销帐成功!’&#41;;”, true); 主要是这段js代码:window.opener.location.reload...

    javascript提示类

    Response.Write("&lt;script&gt;window.open('" + Str1 + "','_blank');window.showModalDialog('close.htm');&lt;/script&gt;"); close.htm文件 代码为 &lt;body onload="window.parent.opener=null;window.close();"&gt; ...

    深入学习JavaScript中的bom

    BOM(Broswer Object Model) 凡是 window 的属性和方法,均可以省略...window.open() 2.在子窗口中使用,表示父窗口的window对象 window.opener window.opener.fatherSayHello(); 调用父窗口的方法 window.opener.a

    window.close(); 关闭浏览器窗口js代码的总结介绍

    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

    js 无提示关闭浏览器页面的代码

    方法一: 代码如下: top.window.opener=null; top.window.open(“”,”_self”); top.window.close(); 方法二: 代码如下: top.window.opener = top; top.window.open(”,’_self’,”); top.window.close(); _blank...

    JS window对象的top、parent、opener含义介绍

    例如:A页面通过window.open()方法弹出了B页面,在B页面中就可以通过opener来引用A页面,这样就可以通过这个对象来对A页面进行操作。 3.parentparent用于在iframe,frame中生成的子页面中访问父页面的对象。例如:A...

    静态页面的值传递(三部曲)

    只要window.opener指向父窗口,就可以访问所有对象. 不仅可以访问值,还可以访问父窗口的方法.值长度无限制. 缺点:两窗口要存在着关系.就是利用window.open打开的窗口.不能跨域. Post.htm &lt;input type=text name=...

    js关闭浏览器窗口及检查浏览器关闭事件

    [removed] function closeWin(){ window.opener=null; window.open(”,’_self’,”); window.close(); } [removed] &lt;a&gt;logout&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; 火狐默认不支持js关闭浏览器窗口,可以在about:...

    javascript常用对象梳理

    熟练掌握window对象的status、location、name、self、opener属性的使用 Window对象是客户端javascript最高层对象之一,只要打开浏览器窗口,不管该窗口中是否有打开的网页,当遇到BODY、FRAMESET或FRAME元素时,...

Global site tag (gtag.js) - Google Analytics