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