在做web程序的时候,有很多情况,尤其软件外包,使用模态窗口的比较多,因为外包大多数情况下,需要有确认画面,所以涉及到传值与历史返回的回传值问题,如果采用 window.open这时候的历史返回就得不到该值,所以采用同一个画面打开选择画面,选择值并提交就成为必要了,应为不是打开2个画面,模态窗口打开的是同一画面,也就是只有一个windows对象。
好了废话不多说了,下面进入正题:
window.showModalDialog() //方法用来创建一个显示HTML内容的模态对话框。
使用方法:
vReturnValue = window.showModalDialog(URL [, Arguments] [,Features])
参数说明:
URL -- 必选参数,类型:字符串。用来指定对话框要显示的文档的URL。
Arguments -- 可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。
Features -- 可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开
-----Features 的可选参数-----------
1. dialogHeight: 对话框高度,不小于100px
2. dialogWidth: 对话框宽度。
3. dialogLeft: 离屏幕左的距离。
4. dialogTop: 离屏幕上的距离。
5. center: { yes | no | 1 | 0 } : 是否居中,默认yes,但仍可以指定高度和宽度。
6. help: {yes | no | 1 | 0 }: 是否显示帮助按钮,默认yes。
7. resizable: {yes | no | 1 | 0 } [IE6+]: 是否可被改变大小。默认no。
8. status: {yes | no | 1 | 0 } [IE6+]: 是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
9. scroll: { yes | no | 1 | 0 | on | off }:是否显示滚动条。默认为yes。
例子
window.showModalDialog('child.htm',window,'dialogWidth=200px;dialogHeight=100px');
这是打开名为child.htm的画面,并将本身的windows控制权限移交给child.htm画面
这样就可以通过打开的child.htm画面来改变父窗口的值
//关闭模块窗口,并将查询到的值赋给父窗口
function setParentValue(){
var parent=window.dialogArguments;
//这个在IE6+好使
parent.document.columns.description.value=document.getElementById("hidDescription").Value;
//这个在IE8下好使
parent.document.getElementById("description").value=document.getElementById("hidDescription").Value;
parent.document.columns.flag.value="UPD";
window.close();
}
分享到:
相关推荐
介绍showModalDialog和showModelessDialog实现模态窗口的使用心得
Selenium目前没有提供对IE模态对话框(即通过showModalDialog方法打开的弹出对话框)的处理。原因在于,模态对话框会将父页面的 JS挂起,直至对话框处理完毕才会继续执行父页面JS。因为Selenium的底层实现是基于JS的,...
javascript 多层模态窗口showModalDialog页面提交及刷新
sharepoint 2010 弹出模式窗口showModalDialog并返回值
js调用模态窗口的asp页面模板。调用示例: var vmyasp="abc.asp?id="+id; var vbt1="页面窗口title"; var vbt2="附加的title"; var myretu=window.showModalDialog("mywindow.asp?bt1="+escape(vbt1)+"&bt2;="+...
本篇文章主要是对JS对话框_JS模态对话框showModalDialog的用法进行了总结介绍,需要的朋友可以过来参考下,希望对大家有所帮助
chrome中弹出模态对话框,通过window.returnValue赋返回值关闭后,有的情况下无法取得返回值。
showModalDialog刷新窗口的例子
网上找了好几个小时没有找到解决办法。最终还是自己解决了。...这样做就是用超链接把返回url转递到用showModalDialog打开的新窗口中,当showModalDialog返回时指到转来的url,最终不刷新父窗口。......
showModalDialog使用例子,父窗口向子窗口传递值,子窗口设置父窗口的值,子窗口关闭的时候返回值到父窗口 纯js 应用广泛 应用广泛
通过实例,详细说明了showModalDialog弹出网页窗口的应用。
This is a `window.showModalDialog()` shim using a modal HTML5 `<dialog>` element and ECMAScript 6 Generators. It was tested in the latest Google Chrome with the *Enable Experimental JavaScript* flag ...
retvalue = window.showModalDialog("modal.html","", "dialogHeight=5;dialogWidth=10;center=1;status=0;resizable=0;help=0");alert (retvalue);}</script></head><body><form ...
在B窗口中添加数据,提交后,要求B窗口自关闭,然后刷新A窗口(父) 代码如下: [removed] function openSubWin() { window.showModalDialog(‘b.html’, ‘newwindow’, ‘height=500, width=400, top=0, left=0, ...
div层实现showModalDialog
showModalDialog参数详解 基本介绍: showModalDialog() (IE 4+ ...window.showModalDialog()方法用来创建一个显示HTML内容的模态对话框。 window.showModelessDialog()方法用来创建一个显示HTML内容的非模态对话框。
showModalDialog参数传递和获
window.showModalDialog以及window.open用法简介 父子窗口传值