JS study notes-BOM

One, BOM browser object model

  1. BOM allows us to operate the browser through JS
  2. A set of objects are provided for us in the BOM to complete the operation of the browser.

3. BOM object:

These objects are stored as attributes of the window object in the browser, and can be used through the window object or directly.

(1)window:

It represents the window of the entire browser, and the window is also a global object in the web page.

Generally, userAgent is used to determine the information of the browser. userAgent is a string, this string contains the content used to describe the browser information, different browsers will have different userAgent

(2)Navigator

: Represents the information of the current browser, and different browsers can be identified through this object.
Insert picture description here
Insert picture description here

(3)Location:

Represents the address bar of the current browser. You can get the address bar information through Location, or operate the browser to jump to the page.

If you print the location directly, you can directly get the path to the current page.

If you directly modify the location attribute to a complete path or relative path, our page will automatically jump to that path.
①assign(): used to jump to other pages, the function is the same as directly modifying the location
②reload(): reloads the current page, the function is the same as the refresh button If a parameter is passed in the method, it will force the cache to be cleared
③replace(): You can use a new page to replace the current page, no history will be generated, and no rollback

(4)History:

Represents the history of the browser. This object can be used to manipulate the history of the browser. Due to privacy reasons, the object cannot obtain specific history records. You can only operate the browser to turn pages forward and backward, and this operation is only available when Effective for this visit.
①length attribute: you can get the number of currently visited links
②back(): you can go back to the previous page, the function is the same as the browser back button
③forward(): you can jump to the next page, and the function is the browser forward button The same
④go(): It can be used to jump to the specified page, and an integer is required as a parameter. 1 means forward one page, equivalent to foward(); 2 means forward two pages, -1 means forward one page...

(5)Screen:

Represents the information of the user's screen, through which the relevant information of the user's display can be obtained.

Guess you like

Origin blog.csdn.net/weixin_45636381/article/details/113379717