function UpdateMemo(id)//弹出编辑框,并保存返回值
{
var pbURL = 'RoomMemoManager.aspx?room_id=' + id;
var returnValue = window.showModalDialog(pbURL, "", "dialogHeight:250px;dialogWidth:400px;center:yes;status:no");
if (typeof (returnValue) != "undefined" && returnValue != null && returnValue != "") {
alert("操作成功");
}
}
上面的returnValue有很重要的作用:returnValue是javascript中html的window对象的属性,目的是返回窗口值,当用window.showModalDialog函数打开一个IE的模式窗口(模式窗口知道吧,就是打开后不能操作父窗口,只能等模式窗口关闭时才能操作)时,用于返回窗口的值,下面举个例子:
在模态页面中,进行修改操作后:
if (rlm.UpdateRoomMemo(RoomID, memo, out message))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>window.returnValue='Update';CloseWin()</script>");
return;
}
else
{
MessageBoxs.Show(message);
}
window.returnValue='Update'这句话就是返回值,来证明操作成功了
实现从模式窗口向父窗口传递值的作用,这个returnValue除了可以是布尔值,整型值等以外还可以是个js数组,用来传递大量数据。
具体showModalDialog等的用法,可以参考msdn