returnvalue是javascript中html的window对象的属性,目的是返回窗口值,当用
window.showmodaldialog函数打开一个ie的模式窗口(模式窗口知道吧,就是打开后不能操作父窗口,只能等模式窗口关闭时才能操作)时,用于返回窗口的值,下面举个例子:
------------------------------------------------------------------------------
//father.html
<html>
<head>
<meta name="generator" content="microsoft visual studio 6.0">
<title></title>
<script language="javascript">
function showmodal(){
var ret = window.showmodaldialog("child.htm",null,"dialogwidth:350px;dialogheight:350px;help:no;status:no");
if (ret){alert('子窗口返回真!');
}else{
alert('子窗口返回假!');
}
}
</script>
</head>
<body>
<input id=button1 type=button value=button name=button1 onclick="showmodal();">
</body>
</html>
------------------------------------------------------------------------------
//child.html
<html>
<head>
<meta name="generator" content="microsoft visual studio 6.0">
<title></title>
<script language="javascript">
function trans(tag){
if (tag==0){
window.returnvalue=false;
} else{
window.returnvalue =true;
}
window.close();
}
</script>
</head>
<body>
<input id=button1 type=button value="返回真" name=button1 onclick="trans(1)">
<input id=button2 type=button value="返回假" name=button2 onclick="trans(0)">
</body>
</html>
-----------------------------------------------------------------------------
这样一来可以实现从模式窗口向父窗口传递值的作用,
这个returnvalue除了可以是布尔值,整型值等以外还可以是个js数组,用来传递大量数据。
具体showmodaldialog等的用法,可以参考msdn。