How to use Windows. open () and window. showmodaldialog ()

Source: Internet
Author: User

Windows. open () usage Overview
I. Windows. open () support environment: javascript1.0 +/jscript1.0 +/nav2 +/ie3 +/opera3 +
Ii. Basic Syntax:
Window. Open (pageurl, name, parameters)
Where:
Pageurl is the sub-window path
Name is the sub-window handle
Parameters is window parameters (parameters are separated by commas)
Iii. Example:
<SCRIPT>
<! --
Window. open ('page.html ', 'newwindow', 'height = 100, width = 400, Top = 0, Left = 0, toolbar = No, menubar = No, scrollbars = No, resizable = No, location = No, status = no ')
// Write a row
-->
</SCRIPT>
After running the script, page.html will be opened in the newwindow of the new form, with a width of 100 and a height of 400. It is 0 pixels away from the screen top, 0 pixels left, no tool bar, no menu bar, no scroll bar, and cannot be adjusted, no address bar, no status bar.
Please compare.
In the preceding example, several common parameters are involved. In addition, there are many other parameters. For details, see section 4.
Iv. Parameters
Here, yes/no can also use 1/0; pixel value is a specific value, in pixels.
Parameter | value range | description
|
Alwayslowered | yes/no | specifies that the window is hidden behind all windows
Alwaysraised | yes/no | specify that the window is suspended above all windows
Depended | yes/no | whether to close the parent window at the same time
Directories | yes/no | whether the directory bar of nav2 and 3 is visible
Height | pixel value | window height
Hotkeys | yes/no | set the Security Exit hotkey in the window without menu bar
Innerheight | pixel value | pixel height of the document in the window
Innerwidth | pixel value | pixel width of the document in the window
Location | yes/no | whether the location bar is visible
Menubar | yes/no | whether the menu bar is visible
Outerheight | pixel value | set the pixel height of the window (including the decorative border)
Outerwidth | pixel value | set the pixel width of the window (including the decorative border)
Resizable | yes/no | whether the window size can be adjusted
Screenx | pixel value | pixel length between the window and the left boundary of the screen
Screeny | pixel value | pixel length between the window and the upper boundary of the screen
Scrollbars | yes/no | whether the window has a scroll bar
Titlebar | yes/no | whether the title bar of the window is visible
Toolbar | yes/no | whether the toolbar of the window is visible
Width | pixel value | pixel width of the window
Z-Look | yes/no | whether the window floated above other windows after being activated

Window. showmodaldialog User Manual
Basic Introduction:
Showmodaldialog () (ie 4 + supported)
Showmodelessdialog () (ie 5 + supported)
The window. showmodaldialog () method is used to create a modal dialog box that displays HTML content.
The window. showmodelessdialog () method is used to create a non-modal dialog box that displays HTML content.
Usage:
Vreturnvalue = Window. showmodaldialog (Surl [, varguments] [, sfeatures])
Vreturnvalue = Window. showmodelessdialog (Surl [, varguments] [, sfeatures])
Parameter description:
Surl --
Required parameter. Type: string. Specifies the URL of the document to be displayed in the dialog box.
Varguments --
Optional parameter; Type: variant. Used to pass parameters to the dialog box. The passed parameter types are not limited, including arrays. The dialog box uses window. dialogarguments to obtain the passed parameters.
Sfeatures --
Optional parameter; Type: String. Used to describe the appearance and other information of the dialog box. You can use one or more of the following, separated by semicolons.
1. dialogheight: the dialog box height. The default unit of dialogheight and dialogwidth in ie4 is em, while that in ie5 is PX. For convenience, when defining the modal mode dialog box, unit with PX.
2. dialogwidth: Dialog Box width.
3. dialogleft: the distance from the left of the screen.
4. dialogtop: the distance from the screen.
5. Center: {Yes | no | 1 | 0}: whether the window is centered. The default value is yes, but the height and width can still be specified.
6. Help: {Yes | no | 1 | 0}: whether to display the Help button. The default value is yes.
7. resizable: {Yes | no | 1 | 0} [ie5 +]: whether the size can be changed. No by default.
8. Status: {Yes | no | 1 | 0} [ie5 +]: whether to display the status bar. The default value is Yes [modeless] or no [modal].
9. Scroll: {Yes | no | 1 | 0 | on | off}: Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.
The following attributes are used in HTA and are not used in general web pages.
10. dialoghide: {Yes | no | 1 | 0 | on | off}: whether the dialog box is hidden when printing or previewing. The default value is no.
11. Edge: {sunken | raised}: Specify the border style of the dialog box. The default value is raised.
12. unadorned: {Yes | no | 1 | 0 | on | off}: No by default.
Parameter transfer:
1. varguments is used to pass Parameters in the dialog box. The type is not limited. For string types, the maximum value is 4096 characters. Objects can also be passed, for example:
-------------------------------
Parent.htm
<SCRIPT>
VaR OBJ = new object ();
OBJ. Name = "51js ";
Window. showmodaldialog ("modal.htm", OBJ, "dialogwidth = 200px; dialogheight = 100px ");
</SCRIPT>
Modal.htm
<SCRIPT>
VaR OBJ = Window. dialogarguments
Alert ("the parameter you passed is:" + obj. Name)
</SCRIPT>
-------------------------------
2. You can use window. returnvalue to return information to the window that opens the dialog box. It can also be an object. For example:
------------------------------
Parent.htm
<SCRIPT>
STR = Window. showmodaldialog ("modal.htm", "dialogwidth = 200px; dialogheight = 100px ");
Alert (STR );
</SCRIPT>
Modal.htm
<SCRIPT>
Window. returnvalue = "str ";
</SCRIPT>

Windows. showmodaldialog instance
Function Description: Click gorup.gif in parent.aspxand a group is displayed. in the aspx window, double-click a row of data in the DataGrid Control on this page, and the value of the "Combination name" column of this row will be filled to the parent. in the txtgoup text box of the ASPX page. The Code is as follows:
Parent. The HTML code of aspx:
//

<SCRIPT>
Function getgroup (OBJ)
{
VaR valu = Window. showmodaldialog ('group. aspx ', window, 'dialogwidth = 700px; dialogheight = 500px; status = no ');
VaR STR;
STR = "document. All." + obj. ID;
If (valu! = "" & Valu! = Undefined) {eval (STR). value = valu ;}
}
</SCRIPT>
HTML code of group. aspx:
<Script language = JavaScript>
Function returnselect (SEL)
{
Window. returnvalue = sel;
Window. Close ();
}
</SCRIPT>
CS code of group. aspx:
Private void dggroup_itemdatabound (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
If (E. Item. itemtype = listitemtype. alternatingitem | E. Item. itemtype = listitemtype. item)
{
E. item. attributes. add ("onmouseover", "c = This. style. backgroundcolor; this. style. backgroundcolor = '# 9ccbf7'; this. style. cursor = 'hand '");
E. Item. Attributes. Add ("onmouseout", "This. style. backgroundcolor = C ");
Datarowview DRV = (datarowview) E. Item. dataitem;
E. Item. Attributes. Add ("ondblclick", "returnselect ('" + DRV. Row ["name"]. tostring () + "');");

 

Prevent aspx pages from opening a new page when submitted in showmodeldialog: add a line between

 

How do I disable the scroll bar on the left of the modal window?

The solution is as follows:
You can add overflow: hidden to the body style of the modal page to disable display.

Body {
Overflow: hidden; border-Right: 0px; padding-Right: 0px; border-top: 0px; padding-left: 0px; Background: # ffffff; padding-bottom: 0px; margin: 0px; border-left: 0px; width: 100%; padding-top: 0px; border-bottom: 0px
}
What is a modal window? What is a non-modal window?

The answer is as follows:
A modal window is common in traditional programming languages. It is used to open a subwindow. If the subwindow is not closed, it cannot operate on its parent window.
When we use showmodelessdialog () to open a window, we do not need to use a window. close () to close it. When it is opened in non-modal mode [ie5], other operations can still be performed in the window that opens the dialog box, that is, the dialog box is not always the top focus, it is automatically closed when the window URL is changed. The mode [ie4] Dialog Box always has focus (Focus cannot be removed until it is closed ). The modal dialog box is associated with the window that opens it. Therefore, when we open another window, their links are still saved and hidden under the activity window.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/moon_f/archive/2009/06/08/4250608.aspx

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.