Home > Web Front-end > JS Tutorial > body text

Detailed explanation of use of showModelessDialog()_Basic knowledge

WBOY
Release: 2016-05-16 19:26:01
Original
1127 people have browsed it

Javascript has many built-in methods to generate dialog boxes, such as: window.alert(), window.confirm(), window.prompt(), etc. However, IE provides more methods to support dialog boxes. Such as:
showModalDialog() (IE 4 supported)
showModelessDialog() (IE 5 supported)

The window.showModalDialog() method is used to create a modal dialog box that displays HTML content. It is a dialog box, so it does not have all the properties of a window generally opened with window.open().

The window.showModelessDialog() method is used to create a non-modal dialog box that displays HTML content.

When we use showModelessDialog() to open a window, we don’t have to use window.close() to close it. When it is opened in non-modal mode [IE5], the window that opens the dialog box can still perform other operations. , that is, the dialog box is not always the top focus, and it automatically closes when the URL of the window that opens it changes. The modal [IE4] dialog box always has focus (the focus cannot be removed until it is closed). The modal dialog box is linked to the window that opened it, so when we open another window, their link relationship is still preserved and hidden under the active window.

The usage method is as follows:
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [, sFeatures])

Parameter description:
sURL
Required parameter, type: string. Used to specify the URL of the document to be displayed in the dialog box.
vArguments
Optional parameters, type: variant. Used to pass parameters to the dialog box. The type of parameters passed is not limited, including arrays, etc. The dialog box obtains the parameters passed in through window.dialogArguments.
sFeatures
Optional parameters, type: string. Used to describe the appearance of the dialog box and other information, you can use one or more of the following, separated by semicolons ";".
DialogHeight is the height of the dialog box, not less than 100px. The default unit of dialogHeight and dialogWidth in IE4 is em, while in IE5 it is px. For convenience, when defining a modal dialog box, use px as the unit.
DialogWidth: Dialog width.
dialogLeft: distance from the left side of the desktop.
dialogTop: distance from the desktop.
center: {yes | no | 1 | 0}: Whether the window is centered, the default is yes, but the height and width can still be specified.
Help: {yes | no | 1 | 0}: Whether to display the help button, the default is yes.
resizable: {yes | no | 1 | 0} [IE5+]: Whether it can be resized. The default is no.
status: {yes | no | 1 | 0} [IE5]: Whether to display the status bar. The default is yes[Modeless] or no[Modal].
scroll:{ yes | no | 1 | 0 | on | off }: Indicate whether the dialog box displays scroll bars. The default is yes.

There are also several attributes used in HTA, which are generally not used in ordinary web pages.
dialogHide:{ yes | no | 1 | 0 | on | off }: Whether the dialog box is hidden during printing or print preview. The default is no.
edge:{ sunken | raised }: Specifies the border style of the dialog box. The default is raised.
unadorned:{ yes | no | 1 | 0 | on | off }: The default is no.

Incoming parameters:
To pass parameters to the dialog box, they are passed through vArguments. There is no limit on the type. For string types, the maximum length is 4096 characters. Objects can also be passed, for example:

test1.htm

test2.htm


test3.htm



Yes Return information to the window that opened the dialog box through window.returnValue, which of course can also be an object. For example:

test4.htm


test5.htm






<script> <BR> var mxh1 = new Array("mxh","net_lover","孟子E章") <BR> var mxh2 = window.open("about:blank","window_mxh") <BR> // 向对话框传递数组 <BR> window.showModalDialog("test2.htm",mxh1) <BR> // 向对话框传递window对象 <BR> window.showModalDialog("test3.htm",mxh2) <BR></script> <script> <BR> var a = window.dialogArguments <BR> alert("您传递的参数为:" + a) <BR></script><script> <BR> var a = window.dialogArguments <BR> alert("您传递的参数为window对象,名称:" + a.name) <BR> </script>FAQ: <script> <BR> var a = window.showModalDialog("test5.htm") <BR> for(i=0;i<a.length;i++) alert(a) <BR></script>1. How to submit in a modal dialog box without opening a new window? <script> <BR> function sendTo() <BR> { <BR> var a=new Array("a","b") <BR> window.returnValue = a <BR> window.close() <BR> } <BR> </script> If your browser is IE5.5, you can use an iframe with a name attribute in the dialog box, and you can set the target to be the name of the iframe when submitting. For IE4, you can use a frame with a height of 0.例如:

 test6.htm
<script> <BR> window.showModalDialog("test7.htm") <BR> </script> test7.htm
if(window.location.search) alert(window.location.search)
 
  
  
  test8.htm

 
 
 

 <script> <BR> if(window.location.search) alert(window.location.search) <BR> </script>


2,可以通过http://servername/virtualdirname/test.htm?name=mxh方式直接向对话框传递参数吗?
 答案是不能。但在frame里是可以的。
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!