Bom_ Basics of JavaScript

Source: Internet
Author: User
Tags object model

The BOM for JavaScript

ECMAScript is the core of JavaScript, but if you want to use JavaScript on the web, then the BOM (Browser object model) is undoubtedly the real core. The BOM provides a number of objects that are used to access the functionality of the browser, regardless of the content of any Web page. Over the years, the lack of a de facto specification has led to a BOM that has both meaning and problem, because the browser provider offers the chamber to expand it as it pleases. As a result, objects shared between browsers became the de facto standard. These objects are available in browsers, largely because they provide interoperability with browsers. The main aspects of the BOM have been incorporated into the HTML5 specification in order to standardize the most basic part of JavaScript in the browser.

PS: The above excerpt from the "JavaScript Advanced Programming", the BOM is the browser window object, provides a lot of window processing API. With more and more webapp frameworks, we need to be familiar with the contents of the BOM when we are dealing with different pages and different Ajax data in the same window.

1, window

The core object of the BOM is window, which represents an instance of the browser. In the browser, the Window object has a dual role, which is both an interface to access the browser window through JavaScript and a ECMAScript-defined Global object.

The following is the third string property of open

2, location

Location is one of the most useful BOM objects that provide information about the documents loaded in the current window, as well as some navigational features. 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 The same object is referenced. The usefulness of the location object is not only manifested in the information it holds in the current document, but also in its resolution of the URL to a separate fragment, allowing developers to access the fragments through different attributes.


3, History

The history object holds the history of the user's Internet access, from the moment the window is opened. Because history is a property of the Window object , each browser window, every tab page, and even each frame has its own history object associated with a particular window object. For security reasons, developers are not aware of the URLs that users have browsed. However, the list of pages accessed by the user can also be backed up and forward without knowing the actual URL.

4, navigator

The Navigator object, first introduced by Netscape Navigator 2.0, is now the de facto standard for identifying client browsers. While other browsers provide the same or similar information in other ways (for example, window.clientinfor-mation in IE and Indow.opera in Opera), navigator objects are all JavaScript-enabled browsing The device is common. As with other BOM objects, the Navigator objects in each browser also have their own properties. The following figure has navigator more important information

5, screen

There are several objects in JavaScript that are not useful in programming, and the screen object is one of them. The screen object is basically used to indicate the capabilities of the client, including information about the display on the outside of the browser window, such as pixel width and height. The screen object in each browser contains different properties, and the following table lists all the properties and browsers that support the corresponding properties. Just use the code below to see the next line.

<! 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.