ShowModalDialog关闭后刷新父页面

 

   项目中用window.showModalDialog(url)打开模态对话框,操作完成后关闭对话框,并刷新父页面;在子窗口用window.dialogArguments.location.reload(true);提示"window.dialogArguments.location为空或不是对象"。

   google之,发现showModalDialog方法的一些参数如下:

使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
参数说明:
sURL
必选参数,类型:字符串。用来指定对话框要显示的文档的URL。
vArguments
可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。
sFeatures
可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。
        dialogHeight 对话框高度,不小于100px,IE4中dialogHeight 和 dialogWidth 默认的单位是em,而IE5中是px,为方便其见,在定义modal方式的对话框时,用px做单位。
   dialogWidth: 对话框宽度。
   dialogLeft: 距离桌面左的距离。
   dialogTop: 离桌面上的距离。
   center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。
   help: {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes。
   resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no。
   status: {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no  [Modal]。
       scroll:{ yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。

   悲催,window.showModalDialog(url, window)不报错,不过继续无效……  

 

   google 之,发现模态网页对话框的工作机制,原来父窗口调用后会一直停留在window.showModalDialog(url, window);这条语句上,也即是说父页面在打开模态对话框的时候js一直停留在其上,整个后面的代码并没有执行。所以可以用如下方法实现刷新父页面:

window.showModalDialog(url, window);
location.reload();

 

   同时,可以接受返回值即var result=window.showModalDialog(url, window);

posted on 2011-12-07 17:03  付之一笑  阅读(2138)  评论(0编辑  收藏  举报

导航