showModelessDialog () use detailed

Source: Internet
Author: User
model| detailed

JavaScript has many built-in methods for generating dialog boxes, such as: Window.alert (), Window.confirm (), Window.prompt (), and so on. However, IE provides more methods to support the dialog box. Such as:
ShowModalDialog () (IE 4+ support)
showModelessDialog () (IE 5+ support)

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

The Window.showmodelessdialog () method is used to create a modeless dialog box that displays HTML content.

When we open the window with showModelessDialog (), we do not have to use Window.close () to close it, when the modeless mode [IE5] Open, Open the dialog window can still do other things, that is, the dialog box is not always the top focus, When the URL of the window that opens it changes, it closes automatically. The modal [IE4] mode dialog box always has the focus (the focus cannot be moved until it closes). The modal dialog box is associated with the window that opens it, so when we open another window, their link relationship is still saved and hidden underneath the active window.

Use the following methods:
Vreturnvalue = window.showModalDialog (sURL [, varguments] [, Sfeatures])
Vreturnvalue = Window.showmodelessdialog (sURL [, varguments] [, Sfeatures])

Parameter description:
    surl
   Required parameters, type: string. The URL used to specify the document to display in the dialog box.
    varguments
   Optional parameters, type: Variant. Used to pass parameters to the dialog box. The parameter types passed are not limited, including arrays, and so on. The dialog box is window.dialogarguments to get the parameters passed in.
    sfeatures
   optional parameter, type: String. Used to describe information such as the appearance of a dialog box, you can use one or more of the following, with a semicolon ";" Separated.
    dialogheight dialog box height, not less than 100px,ie4 dialogheight and dialogwidth The default unit is EM, and the IE5 is PX, and for convenience, When defining a dialog box for modal, use PX as the unit.
  dialogwidth: Dialog box width.
  Dialogleft: The distance from the left side of the desktop.
  Dialogtop: Distance from the desktop.
  Center: {yes | no | 1 | 0}: The window is centered, the default yes, but the height and width can still be specified.
  Help: {yes | no | 1 | 0}: Do you want to show the assistance button, default yes.
  resizable: {yes | no | 1 | 0} [ie5+]: can be changed size. Default No.
  Status: {yes | no | 1 | 0} [ie5+]: Show status bar. Default is yes[Modeless] or no[modal].
    scroll:{Yes | no | 1 | 0 | on | off}: Indicates whether the dialog box displays scroll bars. The default is yes.

There are several attributes that are used in an HTA and are generally not used in general Web pages.
dialoghide:{Yes | no | 1 | 0 | on | off}: Dialog box is hidden when printing or printing preview. The default is No.
edge:{Sunken | raised}: Indicates the border style of the dialog box. Default is raised.
unadorned:{Yes | no | 1 | 0 | on | off}: default is No.

Incoming parameters:
To pass arguments to the dialog box, it is passed through the varguments. Type is not restricted, for a string type, the maximum is 4,096 characters. You can also pass objects, for example:

Test1.htm
<script>
var mxh1 = new Array ("Mxh", "Net_lover", "Mencius E chapter")
var mxh2 = window.open ("About:blank", "Window_mxh")
Passing an array to a dialog box
window.showModalDialog ("test2.htm", MXH1)
Passing a Window object to a dialog box
window.showModalDialog ("test3.htm", Mxh2)
</script>test2.htm
<script>
var a = Window.dialogarguments
Alert ("The parameter you passed is:" + a)
</script>
Test3.htm
<script>
var a = Window.dialogarguments
Alert ("The parameter you pass is a Window object, Name:" + a.name)
</script>

You can return information by Window.returnvalue to the window that opens the dialog box, or you can also be an object. For example:

Test4.htm
<script>
var a = window.showModalDialog ("test5.htm")
for (i=0;i<a.length;i++) alert (A[i])
</script>test5.htm
<script>
function SendTo ()
{
var a=new Array ("A", "B")
Window.returnvalue = A
Window.close ()
}
</script>
<body>
<form>
<input value= "Back" Type=button >
</form>

Problems:
1. How do I commit in a modal dialog box without opening a new window?
If your browser is ie5.5+, you can use an IFRAME with the name attribute in the dialog box, and you can set target as the name of the IFRAME at the time of submission. For ie4+, you can use a frame with a height of 0. For example:

Test6.htm
<script>
window.showModalDialog ("test7.htm")
</script> test7.htm
if (window.location.search) alert (window.location.search)
<frameset rows= "0,*" >
<frame src= "About:blank" >
<frame src= "Test8.htm" >
</frameset> test8.htm
<form target= "_self" method= "Get" >
<input name=txt value= "Test" >
<input type=submit>
</form>
<script>
if (window.location.search) alert (window.location.search)
</script>

2, can you pass the parameters directly to the dialog box by Http://servername/virtualdirname/test.htm?name=mxh Way?
The answer is no. But it's OK in the frame.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.