Home > Web Front-end > JS Tutorial > BOM_basic knowledge of javascript

BOM_basic knowledge of javascript

WBOY
Release: 2016-05-16 15:02:41
Original
1315 people have browsed it

javascript BOM

ECMAScript is the core of JavaScript, but if you want to use JavaScript in the Web, then the BOM (Browser Object Model) is undoubtedly the real core. The BOM provides a number of objects for accessing browser functionality that is independent of any web page content. Over the years, the lack of a de facto specification has made the BOM both interesting and problematic, as browser vendors have been free to extend it as they see fit. As a result, objects shared between browsers become the de facto standard. These objects exist in browsers largely because they provide interoperability with browsers. In order to standardize the most basic parts of JavaScript in browsers, W3C has incorporated the main aspects of BOM into the HTML5 specification.

ps: The above is excerpted from "Javascript Advanced Programming". BOM is the window object of the browser and provides many window processing APIs. With more and more webapp frameworks, we need to process different pages and different ajax data in the same window, and we need to be familiar with the contents of the BOM.

1. window

The core object of BOM is window , which represents an instance of the browser. In the browser, the window object has a dual role. It is both an interface for accessing the browser window through JavaScript and a Global object specified by ECMAScript.

The following is the third string attribute of open

2. location

Location is one of the most useful BOM objects. It provides information about the document loaded in the current window and also provides some navigation functions. In fact, the location object is a very special object, because it is both a property of the window object and a property of the document object; in other words, window.location and document.location refer to the same object. The usefulness of the location object is not only that it saves information about the current document, but also that it parses the URL into independent fragments, allowing developers to access these fragments through different properties.

3. history
The history object stores the user’s online history, starting from the moment the window is opened. Because

history is a property of the window object

, each browser window, each tab, and even each frame has its own history object associated with a specific window object. For security reasons, developers have no way of knowing which URLs a user has viewed. However, with a list of pages the user has visited, it is also possible to go back and forward without knowing the actual URL.

4. navigator


The navigator object, first introduced by Netscape Navigator 2.0, has now become the de facto standard for identifying client browsers. Although other browsers provide the same or similar information in other ways (for example, window.clientInfor-mation in IE and indow.opera in Opera), the navigator object is common to all browsers that support JavaScript. As is the case with other BOM objects, the navigator object in each browser also has its own set of properties. The picture below contains more important information about the navigator

5. screen

There are several objects in JavaScript that are of little use in programming, and the screen object is one of them. The screen object is basically just used to indicate the capabilities of the client, which includes information about the display outside the browser window, such as pixel width and height. The screen object in each browser contains different properties. The following table lists all properties and the browsers that support the corresponding properties. Just use the following code to check it


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template