window.showModalDialog传值并刷新父窗口示例
window.showModalDialog传值并刷新父窗口示例,father.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>传值+刷新父窗口</TITLE>
<mce:script language="javascript"><!--
functionopenson(){
var obj = newObject();
obj.name="张三";
obj.address="中国北京市";
var k=window.showModalDialog("child.html",obj,"dialogWidth:800px;dialogHeight:600p;status:no;");
if(k.type==""){//传递回的type为空的时候才刷新页面。
alert("刷新了"); //为了看效果加的,实际运用中请注掉
location.reload();
}
}
//--></mce:script>
</HEAD>
<BODY>
<inputtype="button" value="打开子窗口"onclick="openson()">
</BODY>
</HTML>
===================================================
child.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<mce:scriptfor="window"event="onload"><!--
var s = new Object();
s.type="";
window.returnValue=s;
vark=window.dialogArguments;
alert(k.name); //使用传递过来的nanme "张三“;
alert(k.address);//使用传递过来的address "中国北京市“;
//--></mce:script>
<mce:scripttype="text/javascript"><!--
function doRefresh(){
var s=new Object();
s.type="";//设置返回值。//这里返回刷新父页面。
window.returnValue=s;
window.close();
}
functiondoNotRefresh(){
var s=newObject();
s.type="OK";//设置返回值,值随便写,不为空就可以。//这里返回不刷新父页面。
window.returnValue=s;
window.close();
}
//--></mce:script>
</HEAD>
<BODY>
<inputtype="button" value="返回刷新"onclick="doRefresh()">
<input type="button" value="返回不刷新"onclick="doNotRefresh()">
</BODY>
</HTML>
window.showModalDialog传值刷新应用示例、
window.showModalDialog传值刷新应用示例,传值+刷新的实际应用
parent3.html
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML4.0 Transitional//EN">
<HTML>
<HEAD>
<title>传值+刷新</title>
<mce:scripttype="text/javascript"><!--
functionshow(){
var params = newArray();
params[0] ="00000000000";
params[1]="1111111111";
params[2]="22222222222";
var style ="dialogHeight:600px;dialogWidth:800px;status:no";
vark=window.showModalDialog("son3.html",params,style);
if(k.type==""){//传递回的type为空的时候才刷新页面。
alert("刷新我了");
location.reload();
}
}
//--></mce:script>
</HEAD>
<BODY>
<inputtype="button" value="open"onclick="show()">
aaaaaaaaaaaaaaaaaanfddddaas
<inputtype="text">
</BODY>
</HTML>
son3.html
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> NewDocument </TITLE>
<mce:scripttype="text/javascript"><!--
var s = newObject();
s.type=""; //设为空就可以刷新父窗口
window.returnValue=s;
var l_array=new Array();
l_array=window.dialogArguments;
varaa=l_array[0];
varbb=l_array[1];
var cc=l_array[2];
alert(aa);
alert(bb);
alert(cc);
function closeWindow(){
window.close();
}
functiondoNotRefresh(){
var s=newObject();
s.type="OK";//设置返回值,值随便写,不为空就可以。//这里返回不刷新父页面。
window.returnValue=s;
window.close();
}
//--></mce:script>
</HEAD>
<BODY>
sdafsdfafasdf<br>
<inputtype="button" value="closeAndRefresh"onClick="closeWindow()" />
<input type="button" value="closeAndRefresh"onClick="doNotRefresh()" />
</BODY>
</HTML>
window.showModalDialog只传值不刷新的示例
window.showModalDialog只传值不刷新的示例,只传值不刷新
parent2.html
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML4.0 Transitional//EN">
<HTML>
<HEAD>
<mce:scripttype="text/javascript"><!--
functionshow(){
var params = newArray();
params[0] ="00000000000";
params[1]="1111111111";
params[2]="22222222222";
var style ="dialogHeight:600px;dialogWidth:800px;status:no";
window.showModalDialog("son2.html",params,style);
}
//--></mce:script>
</HEAD>
<BODY>
<inputtype="button" value="open"onclick="show()">
aaaaaaaaaaaaaaaaaanfddddaas
<inputtype="text">
</BODY>
</HTML>
===================================================
son2.html
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> NewDocument </TITLE>
<mce:scripttype="text/javascript"><!--
var l_array=newArray();
l_array=window.dialogArguments;
varaa=l_array[0];
varbb=l_array[1];
varcc=l_array[2];
alert(aa);
alert(bb);
alert(cc);
//--></mce:script>
</HEAD>
<BODY>
ssssssssssssssssssssssssssssssssss
</BODY>
</HTML>
window.showModalDialog刷新父窗口不传值的示例
window.showModalDialog刷新父窗口不传值的示例,刷新父窗口(没有传值操作) 父页面打开时一定要传window参数
openModalDialog("son.html",window,800,600);
子页面中刷新:
window.dialogArguments.location="parent.html";//parent.html是父页面的地址
实例:
parent.html
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<mce:scripttype="text/javascript"><!--
functionopenModalDialog(url,name,iWidth,iHeight)
{
window.showModalDialog(url,name,'edge:Raised; center: Yes; help: Yes; resizable: Yes; status:No;dialogHeight:'+iHeight+'px;dialogWidth:'+iWidth+'px');
}
functionshow(){
openModalDialog("son.html",window,800,600);
}
//--></mce:script>
</HEAD>
<BODY>
<inputtype="button" value="open"onclick="show()">
</BODY>
</HTML>
================================================
son.html
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> NewDocument </TITLE>
<mce:scripttype="text/javascript"><!--
functionaa(){
self.close();
window.dialogArguments.location="parent.html";
}
//--></mce:script>
</HEAD>
<BODY>
ssssssssssssssssssssssssssssssssss
<inputtype="button" value="close"onclick="aa()">
</BODY>
</HTML>
本文来自: IT知道网(http://www.itwis.com/) 详细出处参考:http://www.itwis.com/html/programme/javascript/20101015/9289.html