基本介绍:
showModalDialog() (IE 4+ 支持)
showModelessDialog() (IE 5+ 支持)
window.showModalDialog() 方法用来创建一个显示HTML内容的模态对话框。
window.showModelessDialog() 方法用来创建一个显示HTML内容的非模态对话框。
使用方法:
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
参数说明:
sURL -- 必选参数,类型:字符串。用来指定对话框要显示的文档的URL。
vArguments -- 可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。
sFeatures -- 可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。
----------------
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 } [IE5+]: 是否可被改变大小。默认no。
8. status: {yes | no | 1 | 0 } [IE5+]: 是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
9. scroll: { yes | no | 1 | 0 | on | off }:是否显示滚动条。默认为yes。
下面几个属性是用在HTA中的,在一般的网页中一般不使用。
10. dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印预览时对话框是否隐藏。默认为no。
11. edge:{ sunken | raised }:指明对话框的边框样式。默认为raised。
12. unadorned:{ yes | no | 1 | 0 | on | off }:默认为no。
参数传递:
1. 要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如:
-------------------------------
parent.htm
<script>
var obj = new Object();
obj.name="icyheart";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
var obj = window.dialogArguments
alert("您传递的参数为:" + obj.name)
</script>
-------------------------------
2. 可以通过window.returnValue向打开对话框的窗口返回信息,当然也可以是对象。例如:
------------------------------
parent.htm
<script>
str =window.showModalDialog("modal.htm", obj, "dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="http://leo1211.iteye.com/";
</script>
---------------------------------------------------------------------------------------------------------------------------------
Firefox 3.0 已经支持window.showModalDialog了,平时很多地方用模态对话框还是很方便的,
下面一个例子,传一个CallBack过去,让子窗口可以调用父窗口的方法。
父窗口: <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- function ShowDialog() { var param = "dialogWidth:400px;dialogHeight:300px;scroll:no;status:no;resizable:no"; return window.showModalDialog("pop.html", GetResult, param); } function GetResult(ret) { alert(ret); document.getElementById("tbTest").value = ret; } //--> </SCRIPT> <input type="button" value="Pop" onclick="ShowDialog();" /> <input type="text" id="tbTest" /> </BODY> </HTML>
子窗口: <HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- function SetValue() { var callBack = window.dialogArguments; if (callBack != undefined && callBack != null) { callBack(Math.random()); } } //--> </SCRIPT> <input type="button" value="SetValue" onclick="SetValue();" /> </BODY> </HTML>
子窗口可以调用父窗口的alert,以及js赋值等,当然就可以ajax了。
不过貌似不能让父窗口提交。这点倒是有点麻烦。可以用ajax处理父窗口的数据提交。
问题解决:
1.子窗体不刷新,总弹出新窗口?
在子窗体应用的文件的head区之间添加代码:
<base target="_self">
这样在打开的子窗体中的链接仍然会在子窗体刷新,而不会跑到新窗口。
相关推荐
javascript代码模块之\Window.ShowModalDialog使用手册
Window.ShowModalDialog使用手册_对话框 .txt 详细
showModalDialog使用例子,父窗口向子窗口传递值,子窗口设置父窗口的值,子窗口关闭的时候返回值到父窗口 纯js 应用广泛 应用广泛
主要介绍了浅谈JavaScript窗体Window.ShowModalDialog使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
showModalDialog和showModelessDialog使用心得
作者:norika 整理日期:2004年6月17日 基本介绍: showModalDialog() (IE 4+ ... 使用方法: vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures]) vReturnValue = window.showMod
showModalDialog及dialogArguments使用
NULL 博文链接:https://qsfwy.iteye.com/blog/587749
Selenium目前没有提供对IE模态对话框(即通过showModalDialog方法打开的弹出对话框)的处理。原因在于,模态对话框会将父页面的 JS挂起,直至对话框处理完毕才会继续执行父页面JS。因为Selenium的底层实现是基于JS的,...
javascript代码模块之如何使用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 ...
div层实现showModalDialog
针对window.showmodaldialog弹出窗体无刷新的详细使用
showModalDialog参数传递和获
JS中showModalDialog 详细使用 基本介绍: showModalDialog() (IE 4+ 支持) showModelessDialog() (IE 5+ 支持) window.showModalDialog() 方法用来创建一个显示HTML内容的模态对话框。 window....
JS中showModalDialog 的使用解析.docx
.txt 2.JavaScript的系统函数学习 .txt 3.js中用于对象的语句——with和for...in语句学习专题.txt 4.smallSoftkey小软键盘,大键盘 5.window.open参数详解 .txt 6.Window.ShowModalDialog使用详解 ...
ShowModalDialog函数的功能: 使用方法: 参数说明: