JavaScript browser object model (BOM summary
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Development tools and key technology: Adobe Dreamweaver JavaScript
Author: Huang Futao
Time to write: on April 29, 2020
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Knowledge points list:
1, pay attention to distinguish:
DOM document object model (DOM) : is used to operate the HTML document, is the interaction between the user and the browser, the change of deletion or omission of some HTML
BOM browser object model: is used for operating the browser, call BOM method to control the browser's behavior, has nothing to do with the web page content
2, BOM description
1) BOM is also the host object
(2) BOM provides many object, used to access the browser's function, these functions have nothing to do with any web content,
(3) of the individual parts of the browser into the BOM one by one, by modifying the properties of these objects, we call them in the method, to control the actions of the browser
(4) the BOM object contains a Window, the Navigator, the Location, History, Screen and so on
In simple terms: BOM enables us to operation by JS browser, provides a set of objects in the BOM, used to complete the work with the browser,
3, the Window object
All browsers support the window object, which represents the browser window
All JavaScript global objects, functions and variables are automatically become a member of the window object,
Global variable attributes of the object is the window,
Global function is the window object method,
Even the HTML DOM document is one of the attributes of the object window:
4, the Navigator object
- represent the current browser information, through object can be used to identify different browser
- for historical reasons, some attributes of the Navigator object is can't help us to identify the browser
- usually we can only use the userAgent information to judge the browser
If through the navigator userAgent cannot judge, can also with some peculiar to the browser object, to determine the browser information, such as: ActiveXObject (IE11 browsers)
5, the History
- object can be used to operate the browser after forward or backward page
- length returns the number of the URL in browser history list,
Methods description
Back () to load a URL before in the history list,
Forward () to load a URL in the history list,
The go () to load a particular page in the history list,
The go (1) is equal to the back ()
The go (1) is equal to the forward ()
6, Location object
- the object encapsulates the browser's address bar information
The Location object attribute
Property description
Hash sets or returns from the well number (#) to the URL (anchor),
The host Settings or returns the current URL hostname and a port number,
The hostname sets or returns the current URL hostname,
Href sets or returns the complete URL,
The pathname sets or returns the current URL path,
Port port sets or returns the current URL,
The agreement protocol sets or returns the current URL,
The search Settings or return from a question mark (?) Start URL (query),
7, the Location object method
Methods description
The assign () - used to jump to other pages, and directly modify the location as
Reload () - to reload the current document, the function and refresh button; If pass a true as a parameter in the method, will be forced to empty the cache refresh the page
The replace () - in a new document to replace the current document, calling out will jump page; Not generate the history record, cannot use the back button back
8, Screen objects
- on behalf of the user's screen information, through the object can get relevant information to the user's display