Address: http://duqiangcise.iteye.com/blog/288430
JSP pop-up window 1. Basic knowledge of window. open ()
1. Window. open () support environment: javascript1.0 +/jscript1.0 +/nav2 +/ie3 +/opera3 +
2. 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)
3. Simple Example:
<Script language = "JavaScript" type = "text/JavaScript">
<! --
Window. open ('page. aspx ', 'newwindow', 'height = 100, width = 400, Top = 0, Left = 0, toolbar = No, menubar = No, scrollbars = No, resizable = No, location = No, status = no ')
-->
</SCRIPT> page. aspx will be opened in newwindow of the new form. The width is 100, the height is 400, 0 pixels away from the screen top, 0 pixels left, no tool bar, no menu bar, no scroll bar, And the size cannot be adjusted, no address bar, no status bar. <! -- And --> are used for some low-version browsers. These low-version Browsers Do not display the code in tags as text.
4. Available parameters: the value of yes/no can also be 1/0. The 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
Status | yes/no | whether to display information in the status 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
Ii. Window. open () applications and skills
1. call with a connection
<Script language = "JavaScript" type = "text/JavaScript">
<! --
Function openwin ()
{
Window. open ("page. aspx "," newwindow "," Height = 100, width = 400, toolbar = No, menubar = No, scrollbars = No, resizable = No, location = No, status = No ")
}
-->
</SCRIPT>
<A href = "#" onclick = "openwin ()"> open a window. </a>
* "#" Is a virtual connection. If you change "#" to a page, a small window is displayed when the page is opened.
2. Close the pop-up window regularly
You only need to add the following code to the window page (note the window page.
<Script language = "JavaScript" type = "text/JavaScript">
Function closeit ()
{
SetTimeout ("self. Close ()", 10000)
}
</SCRIPT> the unit of 10000 is milliseconds. Then, change <body> to <body onload = "closeit ()">.
3. The main window and the pop-up window are in the same page.
Generally, the main window and the pop-up window are two pages respectively. Can they all be on one page? Of course.
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
<Script language = "JavaScript" type = "text/JavaScript">
Function openwin ()
{
OpenWindow = Window. Open ("", "newwin", "Height = 250, width = 250, toolbar = No, scrollbars =" + scroll + ", menubar = No ");
Openmediaworkflow Doc ument. Write ("<body bgcolor = # ffffff> ")
Openmediaworkflow Doc ument. Write ("Openmediaworkflow Doc ument. Write ("new window opened! ")
Openmediaworkflow Doc ument. Write ("</body> ")
Openmediaworkflow Doc ument. Write ("Openmediaworkflow Doc ument. Close ()
}
</SCRIPT>
</Head>
<Body>
<Input type = "button" onclick = "openwin ()" value = "open window"/>
</Body>
</Html>
4. Frequent applications
// ================================================ ==========================================
//
// Code Description: open a new one without the status bar, toolbar, menu bar, and positioning bar,
// A new window with a center position cannot be changed.
//
// Input parameter: pageurl-transfer Link
// Innerwidth-transfer the width of the new window to be opened
// Innerheight-transfer the height of the new window to be opened
//
// Return parameter: None
//
//
// ================================================ ==========================================
Function g_openwindow (pageurl, innerwidth, innerheight)
{
VaR screenwidth = screen. availwidth
VaR screenheight = screen. availheight
VaR startx = (screenwidth-innerwidth)/2
VaR starty = (screenheight-innerheight)/2
Window. open (pageurl, '', 'left = '+ startx +', Top = '+ starty +', width = '+ innerwidth +', Height = '+ innerheight + ', resizable = No, scrollbars = Yes, status = No, toolbar = No, menubar = No, location = no ')
}
Iii. Mode Window Function pop-up window
// ================================================ ========================================================== ================
//
// Code Description: The mode window function is used to open a mode window that does not contain menus, status bars, tool bars, and positioning columns.
//
// Input parameter: pageurl-transfer Link
// Innerwidth-transfer the width of the new window to be opened
// Innerheight-transfer the height of the new window to be opened
// Return parameter: None
//
//
// ================================================ ========================================================== ================
Function g_openmodalwindow (pageurl, innerwidth, innerheight)
{
Window. showmodaldialog (pageurl, null, 'dialogwidth: '+ innerwidth + 'px; dialogheight:' + innerheight + 'px; help: No; unadorned: No; resizable: No; Status: no ')
}
// ================================================ ========================================================== ================
//
// Code Description: The mode window function is used to open a mode window that does not contain menus, status bars, tool bars, and positioning columns, and return values.
//
// Input parameter: pageurl-transfer Link
// Innerwidth-transfer the width of the new window to be opened
// Innerheight-transfer the height of the new window to be opened
// Return parameter: returnvalue returned by the mode form
//
//
// ================================================ ========================================================== ================
Function g_openreturnwindow (pageurl, innerwidth, innerheight)
{
VaR returnv;
Returnv = Window. showmodaldialog (pageurl, null, 'dialogwidth: '+ innerwidth + 'px; dialogheight:' + innerheight + 'px; help: No; unadorned: No; resizable: No; Status: no ')
Return returnv;
}
// ================================================ ========================================================== ================
//
// Code Description: The mode window function is used to open a mode window that does not contain menus, status bars, tool bars, and positioning columns.
//
// Input parameter: pageurl-transfer Link
// Innerwidth-transfer the width of the new window to be opened
// Innerheight-transfer the height of the new window to be opened
// Return parameter: None
//
//
// ================================================ ========================================================== ================
Function g_openreturnmodalwindow (pageurl, innerwidth, innerheight)
{
Window. showmodaldialog (pageurl, null, 'dialogwidth: '+ innerwidth + 'px; dialogheight:' + innerheight + 'px; help: No; unadorned: No; resizable: No; Status: no ');
Return false;
}