JS pop-up window and dialog box

Source: Internet
Author: User
Tags time in milliseconds

JS Overview: A window object is one of the top JavaScript objects on the client. You only need to open a browser window, regardless of whether the window contains a webpage.

When the body, frameset, or frame element is encountered, the window object instance is automatically created. In addition, the instance of this object can also be

Window. open () method creation. Since the window object is the common ancestor of most other objects

You can omit the reference of the window object. For example, the parameter Doc ument. Write () can be abbreviated to document. Write ().

The instance name of the window can be omitted when you release any methods and properties of the window object in the window. For example, set the current mywin window

For the status attribute, you can only use status instead of mywin. Status. However, in event processing, the location attribute and close () are called ()

The instance name must be used for the method or open () method.

Window objects and methods:
It is a top-level object, rather than the properties of another object, that is, the browser window.

Attribute ======
Defaultstatus default status message
Messages in status bar
Statusbar
Statusbar. Visible
The document currently displayed in the document (this attribute is also an object)
Frames lists the array of framework objects in the window in the order they appear in the document (this attribute is also an object ).

)
History List of the history window (this attribute is also an object)
Number of frames in the length window
The complete (absolute) URL of the document displayed in the location window (the property itself is also an object ).

Document. Location obfuscation. The latter is the URL of the currently displayed document. You can change window. Location (replaced by another document ).

But cannot change document. Location (because this is the position of the currently displayed document)
When the name window is opened, the name of the window is assigned.
Opener indicates the window in which the script of the current window is opened using window. Open (this is Netscape Navigator 3.0 Beta 3

A new attribute introduced)
Parent contains the synonym of the current frame window. An attribute of the frame and window objects.
Synonym for self current window or frame
  
Top: Synonym that contains the top-level browser window of the current framework
The synonym for the current window or frame of window, which is the same as self.
Event

 
Method ======
Alert () open an alert message box
Cleartimeout () is used to terminate the work of the setTimeout method.
Close () Close the window
Confirm () opens a confirm message box. You can select OK or cancel. If you click OK, this method returns true

If you press Cancel, false is returned.
Blur () removes focus from the specified window (this is a new method introduced by Netscape Navigator 3.0 Beta 3)
Focus () brings the specified window to the foreground (another new method)
Open () open a new window
Prompt () opens a prompt dialog box. You can type a text in the box and return the entered text to the script.
SetTimeout () waits for a specified period of time in milliseconds, and then runs the command event handler.

Common Methods:
Alert/: Alert ('----'); no return
Promote/
Confirm/confirm ('Are you sure you want to exit? ') Click "OK" to return "true". Otherwise, "false" is returned.
SetTimeout/setTimeout (fucntion, 10) is postponed for 10 milliseconds and function execution is performed.
Cleartimeout/usage cleartimeout (fucntion)
Setinterval/window. setinterval (Code character expression, 10) execute the specified expression every 10 seconds
Clearinterval (function)

Note: The first parameters of setTimeout and setinterval can be strings or pointers,

The row is like "function ()". If a pointer is used, only the function name is written without the parentheses.
When clear functions are used, the cleartimeout and clearinterval parameters are the timer, that is, the return values of the above two functions.

The call is as follows:
VaR im = setinterval ("function1 ()", 5000 );
Clearinterval (IM); (setTimeout calls are exactly the same)

 

JS pop-up window:
Method: window. Open (URL, name, dialogattrs) parameters 2 and 3 are not required
Purpose: open a new window named name. The content of the form is URL, and the window parameter is dialogattrs.
Parameter description:
URL: the URL of the pop-up page.
Name: Window name
Dialogattrs: window style Control Parameters

Window style has the following options. You can select multiple options. If you select multiple options, use commas to separate them:
Toolbar: Specifies whether the window has a Standard toolbar. When the value of this option is 1 or yes, it indicates there is a standard
Toolbar. If the value of this option is 0 or no, no Standard toolbar exists;
Location: Specifies whether the window has an address toolbar. The options have the same value and meaning as toolbar;
Directories: Specifies whether the window has a linked toolbar. The options have the same value and meaning as the toolbar;
Status: Specifies whether the window has a status bar. The value and meaning of the option are the same as those of toolbar;
Menubar: Specifies whether a window has menus. The options have the same value and meaning as toolbar;
Scrollbar: Specifies whether a scroll bar exists when the document in the current window is greater than the window. The value and meaning of the option are the same as those in the toolbar;
Resizable: Specifies whether the window size can be changed. The value and meaning of the options are the same as those of toolbar;
Width: Specify the window width in pixels, which has been replaced by innerwidth;
Height: Specify the window height in pixels, which has been replaced by innerheight;
Outerwidth: Specify the external width of the window in pixels;
Outerheight: Specify the external height of the window in pixels;
Left: Specify the position of the window to the left of the screen in pixels;
Top: Specify the position of the window from the top of the screen in pixels;
Alwayslowered: specifies that the window is hidden behind all windows. The value and meaning of the option are the same as that of the toolbar;
Alwaysraised: specifies that the window floats above all windows. The value and meaning of the option are the same as those of the toolbar;
Dependent: Specify the window to be opened as a child window of the current window, and close it as the parent window is closed. The value and meaning of the option are as follows:

The same toolbar;

Hotkeys: Set the Security Exit hotkey in a new window without a menu bar. The value and meaning of the option are the same as those of toolbar;

Innerheight: sets the pixel height of the document in the window;

Innerwidth: sets the pixel width of the document in the window;

Screenx: Set the pixel length between the window and the left boundary of the screen;

Screeny: Set the pixel length between the window and the upper boundary of the screen;

Titlebar: indicates whether the title bar is visible in a new window. The value and meaning of the option are the same as those of the toolbar;

Z-Look: indicates that when a window is activated, it cannot float on other windows. The value and meaning of the option are the same as that of toolbar.
For example, when using open('test.html ', 'testwindow ','')

 

Dialog Box in JS:
The JS dialog box is divided into a mode dialog box (you must close the dialog box to continue) and a non-mode dialog box (unlimited)
Mode dialog box Syntax:
Window. showmodaldialog (URL, argS, dialogattrs)
Parameter description:
URL: the URL of the pop-up page.
AGRs: parameters passed to the dialog box in the main window, which can be of any type (array or)
Dialogattrs: style parameters in the pop-up window

Simple Description:
1. Parameters 2 and 3 are not required
2. The AGRs parameters can be obtained through window. dialogarguments in the dialog box:

Varargus = Window. dialogarguments; then, you can process the request as required;
3. dialogattrs
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 (;).

Open.
The height of the dialogheight dialog box, which is not smaller than 100px. In ie4, the default unit of dialogheight and dialogwidth is em.

In ie5, PX is used as the unit when defining the modal mode dialog box for convenience.
Dialogwidth: Dialog Box width.
Dialogleft: The left distance from the desktop.
Dialogtop: the distance from the desktop.
Center: {Yes | no | 1 | 0}: whether the window is centered. The default value is yes, but the height and width can still be specified.
Help: {Yes | no | 1 | 0}: whether to display the Help button. The default value is yes.
Resizable: {Yes | no | 1 | 0} [ie5 +]: whether the size can be changed. No by default.
Status: {Yes | no | 1 | 0} [ie5 +]: whether to display the status bar. The default value is Yes [modeless] or no [modal].
Scroll: {Yes | no | 1 | 0 | on | off}: Specifies whether the scroll bar is displayed in the dialog box. The default value is yes.
4. Functions return values

Mode dialog box usage:
Main Window: VaR value = Window. showmodaldialog ('test. js', STRs, 'resizable: Yes ');
In the pop-up box, use window. returnvalue to set the return value. The value obtained above is the value, and you can

This value is processed for interaction.
Note: the application of the mode dialog box lies in its return value. It can return simple escape characters or arrays. The non-mode dialog box is similar

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.