test1.htm:
<div id="div1">此处显示新 Div 标签的内容</div>
<script>
var a = window.showModalDialog("test2.htm",window)
</script>test2.htm:
<input value="修改" type=button onClick="window.dialogArguments.document.getElementById('div1').innerText='mzwu.com';">点击修改按钮后test1.htm中的div1的值变为"mzwu.com",说明调用成功了,这边"window.dialogArguments"即指父窗口。我们再来分析一下原理:
showModalDialog方法共有三个参数,其中第二个参数用来向对话框传递参数,传递的参数类型可以是基本类型,也可是引用类型,对话框则通过window.dialogArguments来取得传递进来的参数。 好了,看下
showModalDialog("test2.htm",window)
其中"window"是一个对象,指的就是test1.htm窗口,那么模态对话框中"window.dialogArguments"自然就是指其父窗口了。
评论(0)
暂无评论。