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
相关文章推荐
- 运用supervisord管理后台运行程序, 以及注意事项
- Qt中如何使用样式表QPalette以及相关注意事项(转)
- JS 阻止键盘输入event.preventDefault 和window.event.returnValue
- D3.js以及通用JS(JavaScript)读取并解析服务器端JSON的注意事项
- C++ Container 以及 STL 相关的常用操作 和 注意事项
- 关于微信网页调用js-sdk相关接口注意事项目(一级域名与二级域名互相干扰!!!)
- zabbix相关命令以及注意事项
- js读取图片以及AJAX上传图片注意事项
- maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)
- JS入门--JS的几种类型以及注意事项
- STM32实例之LED灯闪烁控制以及相关注意事项
- Qt中如何使用样式表QPalette以及相关注意事项
- js 之 continue break return 用法及注意事项
- js笔记2 - 表单value值、return、window.onload与$(document).ready等
- Qt中如何使用样式表QPalette以及相关注意事项
- js里存储键值对以及注意事项
- (转)Qt中如何使用样式表QPalette以及相关注意事项
- jquery.validate.js插件的remote用法以及使用注意事项
- 关于微信网页调用js-sdk相关接口注意事项目(一级域名与二级域名互相干扰!!!)
- js中window.open的参数及注意注意事项