Browser object model BOM summary and Object Model bom Summary
Concept
Browser Object Model (BOM)
BOM provides objects that interact with browser windows independently of content.
BOM is mainly used to manage the communication between windows, so its core object is window
BOM lacks standards, JavaScript syntax Standardization Organization is ECMA, DOM Standardization Organization is W3C,
BOM was initially part of the Netscape Browser standard;
The window object is the Global object in the browser.
Window settings (opening, size, and position)
Intermittent call and timeout call
Dialog Box (prompt box, confirmation box, input box)
Location object (location object contains various attributes and methods)
The navigator object is used to provide information about the user's browser.
The screen object contains information about the user's screen.
The history object contains the user access history.
Open new window
Window. open (URL, name, specs );
URL: the URL to open the page. If no URL is specified, a new blank window is opened.
Name:
_ Blank is opened in a new window. Default Value:
_ Self: the current page is displayed.
Name window name ......
Specs: A comma-separated project list. The following values are supported:
Height = the height of the pixels window. The minimum value is 100.
Width = the width of the pixels window. The minimum value is 100.
Left = pixels top = pixels ......
Example window. open ('','', 'width = 200, height = 200 ');
Close Window
The window. close () method is used to close the browser window.
(DOM window object method)
The close () method closes the top-level browser window with a window.
A window can be closed by calling self. close () or only calling close.
Only Windows opened through JavaScript code can be closed by JavaScript code.
This prevents malicious scripts from terminating users' browsers.
Window Size
Adjust the window size window. resizeTo (width, height );
Adjust window size window. resizeBy (width, height );
Window position
The window. screenLeft attribute returns the X coordinates of the window relative to the screen.
The window. screenTop attribute returns the Y coordinate of the window relative to the screen.
The window. screenX attribute returns the X coordinates of the window relative to the screen.
The window. screenY attribute returns the Y coordinate of the window relative to the screen.
Window visible area size
Document.doc umentElement. clientWidth // offset obtains the height of the entire document.
Document. body. clientWidth
Document.doc umentElement. clientHeight
Document. body. clientHeight
Window vertical scroll bar
Document. body. scrollTop
Document.doc umentElement. scrollTop
Intermittent call
SetInterval (function/name, in milliseconds)
Indicates that the corresponding function (repeated) is executed every time after a certain millisecond)
Timeout call
SetTimeout (function/name, in milliseconds)
Indicates that after a certain period of milliseconds, the corresponding function is executed only once (not repeated)
Clearing Timer: clearInterval (); clearTimeout ();
Prompt box alert ("");
You must close the message box before continuing the operation.
Confirmation box confirm ("");
Confirm ("content to be confirmed ");
Select "OK", return true, select "cancel", and return false
Input box prompt ("", "");
Prompt ("text displayed in the dialog box", "Default Input text ");
Click the cancel button, return null, and click OK. Then, return the entered text.
Location object contains URL information about the current page
Attribute:
Host setting or return the host name and the port number of the current URL.
Port to set or return the port number of the current URL.
Href sets or returns the complete URL. ......
Method:
Assign () loads new documents.
Reload () to reload the current document.
Replace () replaces the current document with a new document.
Partial attributes of the navigator object
AppCodeName: return the code name of the browser.
AppName: the browser name.
CookieEnabled: returns a Boolean value indicating whether the cookie is enabled in the browser.
Platform returns the operating system platform that runs the browser.
AppVersion: returns the platform and version information of the browser.
The userAgent returns the value of the user-agent header sent by the client to the server.
User browser identifier
Var str = window. navigator. userAgent;
Var str = window. navigator. appVersion;
Case-sensitive Conversion
Str. toLowerLocalCase (); To lowercase
Str. toUpperLocalCase (); convert to uppercase
IndexOf () method
Returns the position of the first occurrence of a specified string value.
Syntax: string. indexOf (str, index );
Parameter: str ------- specifies the string value to be retrieved
Index ---- specifies the position where the search starts in the string
Note: The indexOf () method is case sensitive. If the string value to be retrieved does not appear, the method returns-1.
The screen object contains information about the client display screen.
Width returns the screen width of the monitor.
Height returns the screen height of the monitor.
AvailHeight returns the height of the display screen (except for the Windows taskbar ).
AvailWidth returns the width of the display screen (except for the Windows taskbar ).
The history object contains the URL accessed by the user in the browser.
Length returns the number of URLs in the browser history list.
Back () loads the previous URL in the history list.
Forward () loads the next URL in the history list.
Go () loads a specific page in the history list.
History. go (-1) returns one page
History. go (1) Previous Page
Http://www.cnblogs.com/paulirish/ you can go to this blog to have a look, there is operation code;