Javascript BOM and javascriptBOM

Source: Internet
Author: User

Javascript BOM and javascriptBOM

BOM of javascript

ECMAScript is the core of JavaScript, but to use JavaScript on the Web, BOM (Browser object model) is undoubtedly the core. BOM provides many objects for accessing the browser, which are irrelevant to any webpage content. Over the years, BOM has become interesting and problematic due to the lack of de facto specifications, because browser providers can expand it freely according to their own ideas. As a result, the common objects between browsers become the de facto standard. These objects exist in the browser, largely because they provide interoperability with the browser. To standardize the most basic parts of JavaScript in browsers, W3C has incorporated the main aspects of BOM into HTML5 specifications.

Ps: The above is excerpted from javascript advanced programming. BOM is the window object of the browser and provides many APIs for window processing. With more and more webapp frameworks, we need to be familiar with BOM content if we need to process different pages and ajax data in the same window.

1. window

The core object of BOM is window, which indicates an instance of the browser. In a browser, a 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.

Below is the third string attribute of open

2. location

Location is one of the most useful BOM objects. It provides information related to the documents loaded in the current window and some navigation functions. In fact, the location object is a very special object, because it is not onlyProperties of the window objectIn other words, window. location and document. location reference the same object. The location object is useful not only when it stores the information of the current document, but also when it parses the URL into an independent segment so that developers can access these segments through different attributes.


3. history

The history object stores the user's online history, starting from the moment the window is opened. BecauseHistory is the property of the window object.Therefore, each browser window, each tab, and even every framework have their own history object associated with a specific window object. For security reasons, developers cannot know the URLs browsed by users. However, by using the page list accessed by the user, you can also implement backward and forward without knowing the actual URL.

4. navigator

The first Navigator object introduced by Netscape navigator 2.0 has now become a de facto standard for identifying browser clients. Although other browsers provide the same or similar information in other ways (for example, window. clientInfor-mation and indow in Opera. but the navigator object is shared by all browsers that support JavaScript. Similar to other BOM objects, the navigator objects in each browser also have their own attributes. Important information about navigator

5. screen

Several objects in JavaScript are of little use in programming, and the screen object is one of them. The screen Object is basically used to indicate the client's capabilities, including the display information outside the browser window, such as the pixel width and height. The screen Object in each Browser contains different attributes. The following table lists all attributes and browsers that support the corresponding attributes. Simply use the following code to check it.

<!DOCTYPE html>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.