使用IE6.0以上运行以下两个.HTML文件格式(放在同一个文件目录下)(原创)
father.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY onload="window.status='小波资源'">
<form name="form1" id="form1">
<center>
<font color="blue" size="5">get Son Window element value</font><br/>
<input type="text" name="test1" id="test1" value="111"/><br/>
<input type="text" name="test2" id="test2" value="222"/><br/>
<input type="text" name="test3" id="test3" value="333"/><br/>
<input type="text" name="test4" id="test4" value="getSonValue"/><br/>
<input type="button" name="button" id="button" value="TEST" onclick="showModel()"/><br/>
</center>
</form>
</BODY>
</HTML>
<script language="javascript">
function showModel(){
var arrayObj=new Array(document.getElementById("test1").value,document.getElementById("test2").value,document.getElementById("test3").value);
var returnValue=window.showModalDialog("son.html",arrayObj,'dialogWidth:650px;dialogHeight:450px');
if(typeof(returnValue) != "undefined"){
document.all("test1").value=returnValue.t1;
document.all("test2").value=returnValue.t2;
document.all("test3").value=returnValue.t3;
document.all("test4").value=returnValue.t4;
if(returnValue!=null){
if(confirm("Are you refresh???"))
location.reload();//refresh father window.html
}
}
if(returnValue+""=="undefined"){
if(confirm("Are you refresh???"))
location.reload();//refresh father window.html
}
}
</script>
son.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<base target="_self">
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY onload="window.status='小波资源'">>
<form name="son" id="son">
<p align="right"><input type="button" name="refresh" id="refresh" value="refresh" onclick="history.go(0);"/></p>
<p align="center">
<font color="red" size="8">I am another window!!!</font>
<br/>
<input tyep="text" name="t1" id="t1" value="aaa"/><br/>
<input tyep="text" name="t2" id="t2" value="bbb"/><br/>
<input tyep="text" name="t3" id="t3" value="ccc"/><br/>
<input tyep="text" name="t4" id="t4" value="++sonwindow++"/><br/>
<input tyep="text" name="get1" id="get1" value="getFatherValue1"/><br/>
<input tyep="text" name="get2" id="get2" value="getFatherValue2"/><br/>
<input tyep="text" name="get3" id="get3" value="getFatherValue3"/><br/>
</p>
<br/>
<div align="center">
<input type="button" name="getButton" id="getButton" value="getFatherWindowElementValue" onclick="getValue();"/><br/>
<input type="button" name="close" id="close" value="closeSonWindow" onclick="close1();"/><br/>
<input type="text" name="key" id="key" value="getKeyValue" onKeyPress="getKeyValue();" />
</div>
</form>
</BODY>
</HTML>
<script language="javascript">
//alert(document.all("t2").value);
//alert(parent.window.opener.document.getElementById("test1").value);
function getValue(){
var a=window.dialogArguments;
if(a!=null){
document.getElementById("get1").value=a[0];
document.getElementById("get2").value=a[1];
document.getElementById("get3").value=a[2];
}else{
alert("Need to open father window!!!");
}
}
function close1(){
var returnObj=new Object();
returnObj.t1=document.getElementById("t1").value;
returnObj.t2=document.getElementById("t2").value;
returnObj.t3=document.getElementById("t3").value;
returnObj.t4=document.getElementById("t4").value;
window.returnValue=returnObj;
alert("Close son window,and pass son window parameters to father window element!!");
window.opener=null;
window.close();
}
function getKeyValue(){
var key=event.keyCode;
alert("key==="+key);
}
</script>
分享到:
相关推荐
javascript 子窗体父窗体相互传值方法,一般都是用window.open函数,下面脚本之家给出具体的代码。
通过js实现的子窗体与父窗体之间的值传递
子窗体与父窗体之见互相传值实现使用中很频繁,本文以一个小示例抛砖引玉,希望大家可以举一反三
主要介绍了使用JS在父页面和子页面间相互传值方法,子页面可以是window.open弹出的,也可以是iframe框架中的页面,需要的朋友可以参考下
本篇文章主要是对javascript 实现子父窗体互相传值的简单实例进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助
.NET中利用js让子窗体向父页面传值的实现方法.docx
众所周知window.open() 函数可以用来打开一个新窗口,那么如何在子窗体中向父窗体传值呢,其实通过window.opener即可获取父窗体的引用。
Javascript 两个窗体之间传值实现代码javascript中还有一个函数window.showModalDialog也可以打开一个新窗体,不过他打开的是一个模态窗口,那么如何在父窗体和子窗体之间传值呢?我们先看该函数的定义:...
.NET中利用js让子窗体向父页面传值的实现方法,需要的朋友可以参考一下
在js中,我们时常用到用iframe做系统框架,在子页面也,父页面之间的值传递是一个问题,下面是js获取父窗体和子窗体的对象js:
在js中,我们时常用到用iframe做系统框架,在子页面也,父页面之间的值传递是一个问题,下面是js获取父窗体和子窗体的对象js:1.在iframe子页面中获取父页面的元素: a>window.parent.document这个是获取父页面...
js窗体间传值的小demo,这里是一个修改课程的例子,当然通过修改可以做成不过后台的修改,然后一次提交多条记录
代码如下: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/–>使用open方式打开的窗体 //使用地址方式 window.opener.location.href=’m_Shedule_Main.aspx’;...
文字滚动消息广告代码、iframe父与子窗体之间的传值、JS-IE6下PNG透明实例、垂直幻灯滚动代码、无间断滚动信息滚动类、隨机选、自动播放下一曲(音量和进度拖曳、
如何传值在2个页面之间 :要求不刷新父页面,并且不能用Querystring传值 Asp.net地址转义(分析)加强版 Web的桌面提醒(Popup) Using the Popup Object Click button only once in asp.net 2.0 Coalesys PanelBar ...