BOM Essentials Summary
Warm so intimate!! Learn the east, you must summarize, to facilitate themselves, to consolidate their own. Today I would like to summarize some of the points in the BOM:
One, the Windows object
1. Operation of the window
Windows objects are useful for manipulating browser windows. The following four ways to move the window and resize it.
- Moveby (dx,dy)-----Move the browser window horizontally relative to the current position dx pixels and move the dy pixels vertically. DX value is negative, move the window to the left, DY is negative, move the window up.
- MoveTo (x, y)-----Move the window so that his upper-left corner is at the user's (x, y). You can use negative numbers, but this will remove a portion of the window from the viewable area of the screen. The difference between this method and the above moveby is that one is the relative position and the other is the absolute position.
- Resizeby (DW,DH)----relative to the current size of the browser window, adjust its width to dw pixels, and adjust the dy pixel height.
4, Resizeto (w,h)-----To adjust the width of the window to W, height is the size of H, remember here can not use negative numbers.
For example:
Move the window 10 pixels to the right, 20 pixels down
Window.moveby (10,20);
Move the window so that his width is 150 and the height is 300
Window.resuzeto (150,300);
.........
2. Open the connection in the new window!
Using JavaScript, you can use the window.open() method to open a new window when you line to the specified URL.
Grammar:
Document.open (Mimetype,replace);
MimeType: Parameter that specifies the type of document being written.
Replace: parameter that can cause a new document to inherit a history entry from the parent document when this parameter is set.
Important: When the open () method is called and the document content is set using the Write () method, you must remember to close the document with the Close method and force its contents to appear.
2. System dialog box
In addition to pop-up new browser windows, you can also use other methods to pop the message to the user, that is, using the Window object's alert (), confirm (), and PROMT () methods
Aler ("Hellow World"); After invoking the alert () method, the browser will create a system message box with OK An Shu;
Confirm ("Is you sure?") The difference between this and the above message box is that the latter is more or not the option button.
3. Time interval and pause
The SetTimeout () method is used to call a function or evaluate an expression after a specified number of milliseconds.
Syntax: SetTimeout (CODE,MILLISEC); Code: called string; Millisec: The time to wait before executing the code
SetTimeout (function () {alert ("Hellow World";},1000) can of course refer to previously defined functions;
function Sayhellowworld () {
Alert ("Hellow World")};
SetTimeout (sayhellowworld,1000);
When calling settimeout (), it creates a number-paused ID, the pause ID is essentially the ID of the process to defer, after calling settimeout (), it should not execute its code, to cancel the execution of the code will need to use the cleartimeout () Method: Cleatimeout ()
Tip: SetTimeout () executes code only once. If you want to call more than once, use SetInterval () or let code itself call SetTimeout () again.
L History Tour:
History. Objects
History Object
The History object contains the URLs that the user has visited (in a browser window).
The history object is part of the Window object and can be accessed through the Window.history property.
Note: There is no public standard applied to the history object, but this object is supported by all browsers.
IE: Internet Explorer, F: Firefox, O: Opera.
History Object Properties
Length: Returns the number of URLs in the browser history list.
History Object method
Back (): Loads the previous URL in the History list.
Forward () load the next URL in the history list
Go () Loads a specific page in the History list.
JavaScript Browser object Model BOM Essentials summary