Home > front end >  Browser JavaScript object model
Browser JavaScript object model

Time:09-20

A, BOM browser object model (dom)
What is the BOM?
- BOM: browser object model//host object
- BOM provides many object, used to access the browser's function, these functions have nothing to do with any web content,
- BOM of the individual parts of the browser into one object, by modifying the properties of these objects, we call them in the method, to control the actions of the browser

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,
BOM object
Window object
1.- represent the entire browser window, the window at the same time global object is also a web page
2. The Navigator object (netscape)
- represent the current browser information, through the object can be used to identify different browser
3. The Location of the
- represent the current information, the web browser address bar through the Location can access to the address bar information, or operating browser page jump
4. The History
- on behalf of the browser's history, can pass the object to manipulate the browser's history
Due to privacy concerns, the object cannot access to the specific history, only the browser page forward or backward, operation and the operation is only valid when visit
5. Screen
- on behalf of the user's screen information, through the object can obtain relevant information to the user's display

These BOM object in the browser as a window object's properties save
Can through the window object to use, also can be used directly

1. The Navigator
- 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
UserAgent is a string, the string is used to describe the browser information are contained in the content, different browsers have not through the userAgent
2. 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,
The History object method
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)==& gt; The back ()
The go (1)==& gt; Forward ()
3. The Location of the
- 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),
  • Related