Avoid the Cause Analysis of the new form displayed in showModalDialog _ javascript skills

Source: Internet
Author: User
Avoid the Cause Analysis of the new form displayed in showModalDialog. Generally, you need to use window. open. showModalDialog and showModelessDialog to return the value.

1. What are the differences between showModalDialog and showModelessDialog?
ShowModalDialog: after being opened, the input focus is always maintained. You cannot switch to the main window unless the dialog box is closed.

Port. Similar to the running effect of alert.
ShowModelessDialog: after opening, you can randomly switch the input focus. Does not affect the main window (most blocked

Stay.

2. How can I leave a new window in the superconnection between showModalDialog and showModelessDialog?
Add You can. This sentence is generally placed in.

3. How can I refresh the content in showModalDialog and showModelessDialog?
In showModalDialog and showModelessDialog, you cannot press F5 to refresh or bring up a menu. This depends on

Javascript:


Reload...

Replace filename.htm with the webpage name and place it in the webpage you opened. Press F5 to refresh the page.

Cooperation If you press F5, a new window will pop up.

4. How to use javascript to turn off the window opened by showModalDialog (or showModelessDialog.

Must also be used together Otherwise, a new IE window will be opened and closed.

5. Data Transmission skills of showModalDialog and showModelessDialog.
(Author's note: I wanted to write it in the form of a question and answer, but I couldn't figure out how to ask this, so I had .)
This is troublesome. I have changed it several times, but I cannot explain it in the white space (the language level is getting worse and worse). I have to explain it in an example.
Example:
Now you need to read or set a variable var_name in a showModalDialog (or showModelessDialog ).

General transfer method:
Window. showModalDialog ("filename.htm", var_name)
// Pass the var_name variable
When showModalDialog (or showModelessDialog) is read and set:
Alert (window. dialogArguments) // read the var_name variable
Window. dialogArguments = "oyiboy" // set the var_name variable
This method can be met, but what if you want to operate var_name and then change var_id? No

Then perform the operation. This is the limitation of this transfer method.

The following is the recommended transfer method:
Window. showModalDialog ("filename.htm", window)
// No matter what variables you want to operate, only the window object of the main window is passed directly.
When showModalDialog (or showModelessDialog) is read and set:
Alert (window. dialogArguments. var_name) // read the var_name variable
Window. dialogArguments. var_name = "oyiboy" // set the var_name variable

You can also operate the var_id variable.
Alert (window. dialogArguments. var_id) // read the var_id variable
Window. dialogArguments. var_id = "001" // set the var_id variable

You can also operate any object in the main window, such as the elements in the form object.
Window. dialogArguments. form1.index1. value = "this is the value of the index1 element"

6. Multiple showModelessDialog operations.
Because it is very difficult to say, I will be a little lazy and use the Code directly. If I don't understand it, I will send a letter directly (oyiboy # 163.net (

Change # To @) to ask me.

The main function of the following code is to move another showModelessDialog location in a showModelessDialog.

Some js Code of the main file.
Var s11_showmodelessdialog('control .htm' ', window, "dialogTop: 1px; dialogLeft: 1px") // Open Control

Create window
Var s2 = showModelessDialog (''about: blank '', window," dialogTop: 200px; dialogLeft: 300px ")

// Open the controlled window

Control some code of .htm.
Script
// Operation location data. This special operation function is required because the window location data is in the "xxxpx" mode.
Function countNumber (A_strNumber, A_strWhatdo)
{
A_strNumber = A_strNumber.replace (''px '','''')
A_strNumber-= 0
Switch (A_strWhatdo)
{
Case "-": A_strNumber-= 10; break;
Case "+": A_strNumber + = 10; break;
}
Return A_strNumber + "px"
}
Script





The above key parts are:
Window naming method: var s1 = showModelessDialog (''Control

Create .htm'', window, "dialogTop: 1px; dialogLeft: 1px ")
Variable access method: window. dialogArguments. s2.dialogTop

This example is just about the location operation between showModelessDialog and showModelessDialog,

The showModelessDialog interface controls each other's display pages and transmits variables and data. It depends on your efforts.

If you open a mode window and want to close the window and reload the parent window in the window, the Code is as follows:

Response. Write ("
Related Article

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.