您的位置:首页 > 产品设计 > UI/UE

JS模态窗体的运用,以及相关注意事项(有用到window.returnValue)

2013-04-28 17:20 483 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: