Window object in Javascript

Source: Internet
Author: User
To] window objects:

One window attribute

1. Get the object of the current window: window. frameelement

VaR frameobj = Window. frameelement;

Obtain the name of the current window: frameobj. Name

Obtain the number of frames in the current window: frameobj. Length

Get the framework spirit array of the current window: frameobj. frames is also an object and has the Length attribute.

2. Obtain the historical list of the current window

VaR historyobj = Window. history;

History. length the number of pages accessed by the browser

History. Back () is equivalent to the "back" button.

History. Forward () is equivalent to the forward button.

History. Go () page Jump. The parameter is a forward jump. The parameter is a forward jump. The parameter is 0 and the current page is reloaded.

3. Obtain the URL Information of a window. Location

You can jump the page to the specified address by specifying the location property value.

If it is on the local machine, you can jump to another file by specifying the value of this attribute as the relative path

4. Obtain the original window or framework object opener that opens the window.

VaR openobj = Window. opener;

Openobj. Length

Openobj. Name

Openobj. Frames

5. Obtain the parent frame or window object of the current page.

VaR parentobj = Window. parent;

Parentobj. Frames [subscript] parent. Frames [framework name] All child frameworks of the parent framework

6. Obtain the top-level window of the current framework.

VaR topobj = Window. Top;

7 window status information

Window. defaultstatus is displayed by default (that is, when the user opens the window)

Window. Status Dynamic Display

8. Screen Information Acquisition

Visible area width of the webpage: Document. Body. clientwidth;
Visible area height: Document. Body. clientheight;
Visible area width of the webpage: Document. Body. offsetwidth (including the width of the edge and scroll bar )";
Visible area height of the webpage: Document. Body. offsetheight (including the width of the edge )";
Full text width of the webpage: Document. Body. scrollwidth;
Webpage text height: Document. Body. scrollheight;
The height of the page to be rolled (FF): Document. Body. scrolltop;
The height of the page to be rolled (IE): document.doc umentelement. scrolltop;
Left of the webpage to be rolled: Document. Body. scrollleft;
Page body: window. screentop;
Page body part left: window. screenleft;
Screen Resolution Height: window. Screen. Height (commonly used)
Screen Resolution width: window. Screen. Width (commonly used)
Available screen workspace Height: window. Screen. availheight;
Available screen workspace width: window. Screen. availwidth;
Screen position color settings window. Screen. colordepth

Screen pixel/inch settings window. Screen. devicexdpi

2. Window Method

1. Message Box

Window. Alert ()

2. confirmation dialog box

Window. Confirm () OK button returns "true", cancel button returns "false"

3. Input dialog box

Window. Prompt ("displayed prompt information", "default value entered ")

OK button: If a value is entered, the input information is returned. If no information is entered or the default value is not displayed, an empty string is returned.

Cancel button: return null

4. open a new window

VaR win = Window. Open ("url", "winname", "Param ");

URL of the target window

Winname

(1) window name

(2) built-in name:

_ Self: Open the target document in the most used window of the submission form

_ Parent: working document in the parent window showing the current document

_ Blank open a new window

_ Top open the target document in the current window to ensure that the target document occupies the entire window.

Param: window parameters

(1) Whether the toolbar value is displayed: yes/no 1/0

(2) Whether the address value is displayed in the location window: yes/no 1/0

(3) Whether the directories window displays the link Toolbar

(4) Whether the status bar is displayed

(5) Whether menubar displays the menu bar

(6) Whether scrollbars displays the scroll bar

(7) can the size of the resizable window be changed?

(8) Position of the top window from the top of the screen unit: pixels

(9) Left window to the left of the screen

(10) width of the window

(11) height of the window

5. Remove the focus from the window.

Window. Blur ()

6. Focus the specified window

Window. Focus ()

7. Close the window

Window. Close ()

8. latency

VaR timeid = Window. setTimeout (funname, millisec)

Funname: name of the function to be executed

Millisec Interval

Recurrence can be used for repeated execution, and another window method can be used.

VaR timeid = Window. setinterval ("funname", "millisec ")

Termination Delay

Window. cleartimeout (timeid)

Timeid is the return value of setTimeout.

Similarly, cleartimeout (timeid)

Related Article

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.