This article mainly introduces how to use showModalDialog to close the subwindow and refresh the main window in JS, and analyzes the common usage and related usage skills of showModalDialog in detail based on the specific instance form, for more information about how to use showModalDialog in JS to close the subwindow and refresh the main window, the common usage and related usage skills of showModalDialog are analyzed in detail based on the specific instance form, for more information, see
This example describes how to use showModalDialog in JS to close the subwindow and refresh the main window. We will share this with you for your reference. The details are as follows:
Windows. opener. location. reload (), etc.
None of them are what I want. I finally found out what I want to know. Let's take a look.
ShowModalDialog and showModelessDialog
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. Similar to the running effect of alert.
ShowModelessDialog: after opening, you can randomly switch the input focus. It has no effect on the main window (it can be blocked at most.
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 can only rely on javascript. The following is the relevant code:
reload...
Replace filename.htm with the webpage name and place it in the webpage you opened. Press F5 to refresh the page. Note that this should workIf 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 togetherOtherwise, 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 reading and setting showModalDialog (or showModelessDialog): 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? You cannot perform the operation again. This is the limitation of this transfer method.
The following is the recommended transfer method:
Window. showModalDialog ("filename.htm", window) // no matter what variable 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 was very difficult to say, I was just a little lazy and I simply used the code.
The main function of the following code is to move another showModelessDialog location in a showModelessDialog.
Some js Code of the main file.
Var comment '', window," dialogTop: 1px; dialogLeft: 1px ") // open the control window var s2 = showModelessDialog (''about: blank'', window, "dialogTop: 200px; dialogLeft: 300px ") // open the controlled window
Control some code of .htm.
Script // operation location data. Because the window location data is in the "xxxpx" mode, such a special operation function is required. 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 s11_showmodelessdialog('control .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. Through this principle, the showModelessDialog 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:
The Code is as follows:
Response. Write ("