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