"JS Advanced Program Design" of the Six

Source: Internet
Author: User

1, window position.

IE, Safari, Opera, and chrome all offer properties for Screenleft and Screentop, and Firefox uses Screenx and ScreenY (both of which are supported by Safari and Chrome). Represents the position of the window relative to the left and top of the screen, respectively.

In IE, Opera, and Chrome, Screenleft and Screentop hold the distance from the left and top of the screen to the visible area of the page represented by the Window object. In other words, if the window object is the outermost object and the browser window is close to the top of the screen-that is, the Y coordinate is 0-then the screentop value is the pixel height of the browser toolbar above the visible area of the page. However, in Firefox and Safari, Screeny or screentop holds the coordinate values of the entire browser window relative to the screen.

2, MoveTo () and Moveby () can move the window precisely to a new position.

MoveTo (0,0)  // Move the window to the upper-left corner of the screen Moveby (0,100)    // move the window down 100 pixels  The two digits in parentheses are preceded by a width, and then the height. 

3, window size.

Outerwidth and Outerheight return the dimensions of the browser window itself, Innerwidth and innerheight represent the size of the Page view area in the container (minus the border width).

IE (Standard mode 6.0 and later), Firefox, Safari, Opera, Chrome Document.documentElement.cllientWidth Document.documentElement.cllientHeight
IE (6.0 version promiscuous mode) Document.body.cllientWidth Document.body.cllientHeight
Chrome Standard or Promiscuous mode Both of these methods can be

6. Check Document.compatmode to determine if the page is in standard mode.

7, Resizeto () and Resizeby () can adjust the new width and new height of the browser window.

  

// adjust to 100x100 Window.resizeby (100,150);  // width and height are adjusted by 100 and 150 pixels respectively

8, window.open () receives four parameters, the URL to load, the window target, an attribute string, and a Boolean value that indicates whether the new page supersedes the currently loaded page in the browser history.

The second parameter can be:

_self Open a linked document in the same window
_parent Open in parent window
_top Opens in the current entire browser window, the original frame disappears
_blank In addition, open a new window

9, intermittent call and timeout call.

SetTimeout () Execute code after the specified time SetTimeout (function () {alert ("Heollo world!")},1000) Cleartimeout (Timeoutid) cancels a timeout call plan that has not yet been executed
SetInterval () Executes the code once every specified time SetInterval (function () {alert ("Heollo world!")},1000) Clearinterval () cancels an indirect call

JS is a single-threaded interpreter that can only execute a piece of code over a period of time. It is best not to use intermittent calls.

"JS Advanced Program Design" of the Six

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.