Author: Flash Source: how to force the pop-up window to always be at the top
Solution :
In general, the front window is displayed because the window is activated to obtain the focus. To make the window always display at the front, you can set the focus of the window at blur, you can also use the mode or mode-free dialog box.
Procedure :
Method 1: In the pop-up window, add the code onblur = "self. Focus ()":
<Body onblur = "self. Focus ()">
Method 2: Use the showmodaldialog method to create a mode dialog box. Its parameter descriptions are shown in Table 1.5.2.
<SCRIPT>
Function topwin (){
Window. showmodaldialog ("http://www.thugx.com", "", "dialogwidth: 300px; dialogheight: 300px; scroll: No; Status: No ")
}
</SCRIPT>
<Button onclick = "topwin ()"> open the mode window </button>
Method 3: Use the showmodelessdialog method to create a mode-free dialog box. Its parameters are exactly the same as those in the mode dialog box. For details, see Table 1.5.2.
<SCRIPT>
Function topwin (){
Window. showmodelessdialog ("http://www.thugx.com", "", "dialogwidth: 300px; dialogheight: 300px; scroll: No; Status: No ")
}
</SCRIPT>
<Button onclick = "topwin ()"> open the mode-free window </button>
Note: The mode Dialog Box always keeps focus. The window cannot be switched unless the dialog box is closed. In the mode-free dialog box, the focus is not always maintained, but the focus is always displayed at the frontend.
Note
Methods 2 and 3CodeThe running effects are shown in 1.5.4 and 1.5.5 respectively.
Figure 1.5.4 dialog box
Figure 1. 5.5 Effect of the modeless dialog box
Note
In this example, the application of the mode dialog box and the mode-free dialog box is used. Note the similarities and differences between the two dialog boxes.
Table 1.5.2 parameters of the showmodaldialog Method
Parameter value description
Surl is required. String ). Specify the URL to load and display.
Varguments is optional. String ). Specifies the variables used to display documents. This parameter can be used to pass any type of value, including multiple worthwhile arrays. The dialog box can be called Program Extract these values from the dialogarguments attribute of the window object.
Sfeatures is optional. String ). Specify the window decoration of the dialog box. Use the following values. Separated by semicolons.
Dialogheight: height of the sheight Setting Dialog Box
Dialogleft: the horizontal coordinate relative to the desktop in the upper left corner of the sxpos Setting dialog box.
Dialogtop: Y coordinate relative to the desktop in the upper left corner of the sypos Setting dialog box.
Dialogwidth: the width of the swidth Setting dialog box.
Center: Yes | no | 1 | 0 | on | off specifies whether the dialog box is displayed in the center of the desktop. The default value is yes.
Dialoghide: Yes | no | 1 | 0 | on | off specifies whether the dialog box is hidden when printing or previewing. This parameter is only available when the dialog box is opened by a trusted program. The default value is no.
Edge: sunken | raised specifies whether the border style of the dialog box is concave or convex. The default value is raised.
Help: Yes | no | 1 | 0 | on | off specifies whether the context-related help icon is displayed in the dialog box. The default value is yes.
Resizable: Yes | no | 1 | 0 | on | off specifies whether the dialog box can be changed by the user. The default value is no.
Scroll: Yes | no | 1 | 0 | on | off specifies whether a scroll bar is displayed in the dialog box. The default value is yes.
Status: Yes | no | 1 | 0 | on | off specifies whether the dialog box shows status bars. The default value of the untrusted dialog box is yes. The default value of the trusted dialog box is no.
Unadorned: Yes | no | 1 | 0 | on | off specifies whether the chrome style border is displayed in the dialog box. This parameter is only available when the dialog box is opened by a trusted program. The default value is no.