关于window.showModalDialog 的简单应用,父子窗口之间的传递

关于window.showModalDialog 的简单应用,父子窗口之间的传递

parent.htm

< script >
function showmd(id)
{
var sRet = window.showModalDialog( " md.htm?id= " + id,window, " scroll:0;status:0;help:0;resizable:0;dialogWidth:200px;dialogHeight:170px " );
if (sRet == " refresh " ) // 子窗口返回的值
{
window.location.reload();
}
}
</ script >
< input type ="button" value ="显示对话框" onclick ="showmd('35')" />


md.htm

< script >
function closemd()
{
var parentwindow = window.dialogArguments; // 接父窗口传来的对象
window.returnValue = " refresh " ; // 传回父窗口的值
parentwindow.location = " http://www.baidu.com " ;
window.close();
}
</ script >
< input type ="button" value ="关闭对话框" onclick ="closemd()" />

传递对象到子窗口 和 返回值到父窗口 的代码都以示出

你可能感兴趣的:(关于window.showModalDialog 的简单应用,父子窗口之间的传递)