Javascript operation window object, javascriptwindow

Source: Internet
Author: User

Javascript operation window object, javascriptwindow

Document. defaultView or global variable window -- get a window object;

1) Obtain window information

InnerHeight and innerWidth -- Obtain the height and width of the window content area;

OuterHeight and outerWidth -- Obtain the window height and width (including the border and menu bar );

PageXOffset and pageYOffset -- get the number of vertices that have been horizontally or vertically rolled in the upper left corner of the window;

Screen -- returns a Screen object that describes the screen;

Screen. availHeight and screen. availWidth: the height and width of the window section on the screen (excluding the toolbar and menu bar );

Screen. colorDepth-the color depth of the screen;

Screen. height, screen. width -- screen height and width;

ScreenLeft/screenX -- get the pixels from the left edge of the window to the left edge of the screen (note browser compatibility );

ScreenTop/screenY -- get the pixels from the edge of the window to the edge of the screen (note browser compatibility );

2) interact with the window

Blur () -- disables the keyboard focus of the window;

Close () -- close the window (not all browsers allow a script to close the window );

Focus () -- let the window get the keyboard focus;

Print () -- prompt the user to print the page;

ScrollBy (<x>, <y>) -- scroll the document relative to the current position;

ScrollTo (<x >,< y>) -- scroll to the specified position;

Stop () -- stop loading documents;

3) prompt the user

Alert (<msg>) -- prompt the user for a dialog box window and wait until it is closed;

Confirm (<msg>) -- displays a dialog box with confirmation and cancellation prompts (returns a Boolean value );

Prompt (<msg >,< val>) -- The displayed dialog box prompts the user to enter a value (return string );

ShowModalDialog (<url>) -- a window is displayed, showing the specified URL;

4) attributes and methods of the history Object

Back () -- step back in browsing history;

Forward () -- before browsing history;

Go (<index>) -- go to a historical position relative to the current document. Positive is forward, negative is backward;

Length -- returns the number of projects in the browsing history;

PushState (<state >,< title >,< url>) -- Add an entry to the browser history;

ReplaceState (<state >,< title >,< url>) -- replace the current entry in the browser history;

State -- return the state data associated with the current document in the browser history;

5) use cross-document message transmission

PostMessage (<msg>, <origin>) -- sends the specified message to another document;

Find the embedded window:

DefaultView -- return the window of the activity document;

Frames -- returns the array of window objects embedded with the iframe element in the document;

Opener -- returns a window that opens the context of the current browser;

Parent -- returns the parent window of the current window;

Self -- return the window of the current document;

Top -- return the top window;

Length -- returns the number of embedded iframe elements in the document;

[<Index>] -- returns the window of the embedded document at the specified index position;

[<Name>] -- return the window of the embedded document with the specified name;

6) use a timer

SetTimeout (<function >,< time>) -- creates a timer and calls the specified function in milliseconds;

ClearTimeout (<id>) -- cancels a time-out timer;

SetInterval (<function >,< time>) -- creates a timer and calls the specified function every milliseconds;

ClearInterval (<id>) -- cancels a time interval timer;

<! DOCTYPE html> 

OtherPage code:

<! DOCTYPE html> 



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.