test1.htm
<script>
var mxh1 = new Array("mxh","net_lover","孟子E章")
var mxh2 = window.open("about:blank","window_mxh")
// 向对话框传递数组
window.showModalDialog("test2.htm",mxh1)
// 向对话框传递window对象
window.showModalDialog("test3.htm",mxh2)
</script>test2.htm
<script>
var a = window.dialogArguments
alert("您传递的参数为:" + a)
</script>
test3.htm
<script>
var a = window.dialogArguments
alert("您传递的参数为window对象,名称:" + a.name)
</script>
可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如:
test4.htm
<script>
var a = window.showModalDialog("test5.htm")
for(i=0;i<a.length;i++) alert(a[i])
</script>
test5.htm
<script>
function sendTo()
{
var a=new Array("a","b")
window.returnValue = a
window.close()
}
</script>
<body>
<form>
<input value="返回" type=button onclick="sendTo()">
</form>