js中window.showModalDialog()方法的用法
父窗口的js代码:
<script type="text/javascript">
function testalert() {
var returnval = window.showModalDialog('default.aspx', 'example04','dialogWidth:400px;dialogHeight:300px;center:yes;help:yes;resizable:yes;status:yes');
alert(returnval);
}
</script>
然后调用这个方法,弹出一个新窗口'default.aspx'
新窗口的js代码
<script type="text/javascript">
function closeWindow() {
window.returnValue = 'OK';//设置返回值
window.close();
}
</script>
在body 拖一个button按钮 调用这个方法
还有一个关键地方:在head 部分加上这句话
<base target="_self">
不然会新打开一个页面。