Creates a modal dialog box that displays the specified HTML document.
Syntax
vReturnValue = object.showModalDialog(sURL [, vArguments] [, sFeatures])
Parameters
sURL |
Required. String that specifies the URL of the document to load and display. |
vArguments |
Optional. Variant that specifies the arguments to use when displaying the document. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values passed by the caller from the dialogArguments property of the window object. |
sFeatures |
Optional. String that specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:
dialogHeight:sHeight
Sets the height of the dialog window (see Remarks for default unit of measure).
dialogLeft:sXPos
Sets the left position of the dialog window relative to the upper-left corner of the desktop.
dialogTop:sYPos
Sets the top position of the dialog window relative to the upper-left corner of the desktop.
dialogWidth:sWidth
Sets the width of the dialog window (see Remarks for default unit of measure).
center:{ yes | no | 1 | 0 | on | off }
Specifies whether to center the dialog window within the desktop. The default is yes.
dialogHide:{ yes | no | 1 | 0 | on | off }
Specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. The default is no.
edge:{ sunken | raised }
Specifies the edge style of the dialog window. The default is raised.
resizable:{ yes | no | 1 | 0 | on | off }
Specifies whether the dialog window has fixed dimensions. The default is no.
scroll:{ yes | no | 1 | 0 | on | off }
Specifies whether the dialog window displays scrollbars. The default is yes.
status:{ yes | no | 1 | 0 | on | off }
Specifies whether the dialog window displays a status bar. The default is yes for untrusted dialog windows and no for trusted dialog windows.
unadorned:{ yes | no | 1 | 0 | on | off }
Specifies whether the dialog window displays the border window chrome. This feature is only available when a dialog box is opened from a trusted application. The default is no.
|
Return Value
Variant. Returns the value of the returnValue property as set by the window of the document specified in sURL.
Remarks
A modal dialog box retains the input focus while open. The user cannot switch windows until the dialog box is closed.
Because a modal dialog box can include a URL to a resource in a different domain, do not pass information through the vArguments parameter that the user might consider private. The vArguments parameter can be referenced within the modal dialog box using the dialogArguments property of the window object. If the vArguments parameter is defined as a string, the maximum string length that can be passed to the modal dialog box is 4096 characters; longer strings are truncated.
As of Microsoft Internet Explorer 4.0, you can eliminate scroll bars on dialog boxes. To turn off the scroll bar, set the SCROLL attribute to false
in the body element for the dialog window, or call the modal dialog box from a trusted application.
Internet Explorer 5 and later allows further control over modal dialog boxes through the status
and resizable
values in the sFeatures parameter of the showModalDialog method. Turn off the status bar by calling the dialog box from a trusted application, such as Microsoft Visual Basic or an HTML Application (HTA), or from a trusted window, such as a trusted modal dialog box. These applications are considered to be trusted because they use Windows Internet Explorer interfaces instead of the browser. Any dialog box generated from a trusted source has the status bar turned off by default. Resizing is turned off by default, but you can turn it on by specifying resizable=yes
in the sFeatures string of the showModalDialog method.
You can set the default font settings the same way you set Cascading Style Sheets (CSS) attributes (for example, "font:3;font-size:4"
). To define multiple font values, use multiple font attributes.
The default unit of measure for dialogHeight
and dialogWidth
in Internet Explorer 5 and later is the pixel. The value can be an integer or floating-point number, followed by an absolute units designator (cm
, mm
, in
, pt
, or pc
) or a relative units designator (em
, ex
, or px
). For consistent results, specify the dialogHeight
and dialogWidth
in pixels when designing modal dialog boxes.
For Internet Explorer 7, dialogHeight
and dialogWidth
return the height and width of the content area and no longer includes the height and width of the frame.
Internet Explorer 7. Although a user can manually adjust the height of a dialog box to a smaller value —provided the dialog box is resizable— the minimum dialogHeight
you can specify is 100 pixels, and the minimum dialogWidth
you can define is 250 pixels. In versions earlier than Internet Explorer 7 the minimum value of the dialogWidth
that can be specified is 100 pixels.
To override center
, even though the default for center
is yes
, you can specify either dialogLeft
and/or dialogTop
.
This method must use a user-initiated action, such as clicking on a link or tabbing to a link and pressing enter, to open a pop-up window. The Pop-up Blocker feature in Internet Explorer 6 blocks windows that are opened without being initiated by the user.
Note For Internet Explorer 7, help
is not a valid value for sFeatures
. In previous versions, help:{ yes | no | 1 | 0 | on | off }
specified whether the dialog window displays the context-sensitive Help icon.
When Internet Explorer opens a window from a modal or modeless HTML dialog box by using the showModalDialog method or by using the showModelessDialog method, Internet Explorer uses Component Object Model (COM) to create a new instance of the window. Typically, the window is opened by using the first instance of an existing Internet Explorer process. When Internet Explorer opens the window in a new process, all the memory cookies are no longer available, including the session ID. This process is different from the process that Internet Explorer uses to open a new window by using the open method.
Examples
This example uses the showModalDialog method to open a customized dialog box.
<script type="text/javascript">
function fnRandom(iModifier){
return parseInt(Math.random()*iModifier);
}
function fnSetValues(){
var iHeight=oForm.oHeight.options[
oForm.oHeight.selectedIndex].text;
if(iHeight.indexOf("Random")>-1){
iHeight=fnRandom(document.body.clientHeight);
}
var sFeatures="dialogHeight: " + iHeight + "px;";
return sFeatures;
}
function fnOpen(){
var sFeatures=fnSetValues();
window.showModalDialog("showModalDialog_target.htm", "",
sFeatures)
}
</script>
<form name="oForm">
Dialog Height
<select name="oHeight">
<option>-- Random --</option>
<option>150</option>
<option>200</option>
<option>250</option>
<option>300</option>
</select>
Create Modal Dialog Box
<input type="button" value="Push To Create" onclick="fnOpen()">
</form>
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm
Linked from the following button is an extended version of the above script, which demonstrates many of the features available for creating a custom dialog box.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog.htm
Neither modal nor modeless HTML dialog boxes support text selection or the standard shortcut menu for copy operations; however, you can imitate this functionality by using script with TextRange objects and event handlers for onmousedown and onmousemove, as in the following example.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialogLaunch.htm
使用dialogArguments 得到父窗口传递的参数
window.showModalDialog(url,'',
"dialogHeight: 550px; dialogWidth: 750px;center: yes; help: no;resizable: no; status: no;");
相关推荐
### showModalDialog和showModelessDialog使用心得:深入解析与实践 在Web开发中,`showModalDialog` 和 `showModelessDialog` 是两种用于创建弹出窗口的方法,它们各自具有独特的特性和应用场景。本文将详细解析这...
在标题提到的问题中,当使用`showModalDialog`并结合`iframe`来实现弹窗功能时,如果页面被刷新,可能会出现一个新的弹出窗口。这是因为`showModalDialog`通常会保留其状态,而页面刷新会重置这些状态,导致再次调用...
本篇文章将深入探讨`showModalDialog`的使用方法、参数、返回值以及它在现代Web开发中的地位。 `showModalDialog`的基本语法如下: ```javascript window.showModalDialog(url, windowObject, features); ``` 1. ...
本篇文章将深入探讨`showModalDialog`的参数使用,以及如何在子父窗口之间传递数据。 `showModalDialog`函数的基本语法如下: ```javascript window.showModalDialog(url, [startNode], [features]); ``` - `url`...
下面是一些使用`showModalDialog()`的示例: ```javascript // 基本用法,打开一个HTML文件 var result = window.showModalDialog("dialog.html"); // 传递参数 var result = window.showModalDialog("dialog....
在自动化测试领域,Selenium 是一个广泛使用的工具,它允许测试人员通过编写代码来模拟用户在Web应用程序上的交互。然而,对于某些特定的功能,比如 Internet Explorer 中的 `showModalDialog` 方法,Selenium 存在...
ShowModalDialog 填充这是一个window.showModalDialog() shim,使用模态 HTML5 <dialog>元素和 ECMAScript 2015 Generators 或 ECMAScript 2017 Async/Await。 它在最新的 Google Chrome 和最新的 Mozilla Firefox ...
今天使用showModalDialog打开页面,返回值时。当打开的页面点击关闭按钮或直接点浏览器上的关闭则返回值是undefined所以自作聪明判断 var reValue=window.showModalDialog(“”,””,””); if (reValue== ...
本文实例讲述了JS中showModalDialog关闭子窗口刷新主窗口用法。分享给大家供大家参考,具体如下: 网上找了好长时间 大都是window.opener.location.reload(),等等 都不是我想要的 最后终于发现了一个 想知道的就往下...
下面将详细介绍`showModalDialog`的使用、功能、优缺点以及相关的HTML和JavaScript知识。 `showModalDialog`的基本语法如下: ```javascript window.showModalDialog(url, [startValue], [features]); ``` 1. `...
在Web开发中,有时我们...需要注意的是,这两个方法在现代浏览器中支持度有限,尤其是跨浏览器兼容性问题,因此在新的项目中可能会考虑使用更通用的解决方案,如Bootstrap的模态框或者其他前端框架提供的对话框组件。
这篇名为"showModalDialog技术文章"的博客文章可能详细介绍了这个API的使用方法、优缺点以及一些实际应用场景。 `showModalDialog`函数在JavaScript中被用来创建一个阻塞式的对话窗口,这意味着用户必须与对话框...
下面我们将详细探讨`window.showModalDialog`的使用及其相关知识点。 首先,`window.showModalDialog`的基本语法如下: ```javascript var returnValue = window.showModalDialog(url, [dialogArguments], ...
本文将详细介绍`window.showModalDialog`的使用方法及其相关知识点。 1. **基本语法** `window.showModalDialog` 的基本调用形式如下: ```javascript var returnValue = window.showModalDialog(url, window, ...
由于`showModalDialog`不支持最新的Web标准,存在许多问题,如不兼容性(主要在IE浏览器中使用)、无法进行CSS3和JavaScript增强以及阻塞主线程等。因此,现代Web开发通常使用更灵活的替代方案,如`<dialog>`元素、...
1. 标准的方法 代码如下: [removed] function openWin(src, width, height, showScroll){ window.showModalDialog (src,””,”location:No;status:No;help:No;dialogWidth:”+width+”;dialogHeight:”+height+”;...
然而,当尝试使用`showModalDialog`在不同源之间打开页面时,同样会遭遇跨域限制。标题"showModalDialog跨域解决例子"表明我们将探讨如何克服这个限制。 首先,理解跨域的原理至关重要。同源策略是浏览器为了安全而...
`showModalDialog` 是一个非常实用的功能,允许创建模态对话框(即用户必须与之交互才能继续使用页面其他部分的窗口)。然而,在某些情况下,我们可能希望在关闭弹出窗口后,不刷新父窗口(即打开弹出窗口的页面),...
其中,open() 方法和 showModalDialog() 方法是经常被使用的两种,它们有着各自的特点和应用场景。 首先,让我们详细了解一下 open() 方法。open() 方法用于打开一个新的浏览器窗口或者一个新的标签页,并可以对新...
### showModalDialog及dialogArguments使用详解 在Web开发中,`showModalDialog` 和 `showModelessDialog` 是Internet Explorer浏览器特有的方法,用于打开模态或非模态对话框。这两个函数允许开发者创建自定义的弹...