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. : P)
2. How can I leave a new window in the superconnection between showmodaldialog and showmodelessdialog?
Add <base target = "_ Self"> to the opened webpage. This sentence is generally placed between <HTML> and <body>.
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 only on JavaScript.Code:
<Body onkeydown = "If (event. keycode = 116) {reload. Click ()}">
<A id = "reload" href = "filename.htm" style = "display: none"> reload... </a>
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 be used with <base target = "_ Self">, otherwise press F5 to bring up a new window.
4. How to use JavaScript to turn off the window opened by showmodaldialog (or showmodelessdialog.
<Input type = "button" value = "close" onclick = "window. Close ()">
Also use <base target = "_ Self">. 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? 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 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.
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 the control window
VaR S2 = showmodelessdialog ('about: blank ', window, "dialogtop: 200px; dialogleft: 300px") // open the controlled window
control some code of .htm.
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.