HTML Dom tutorial Part2 [browser object] extracted from W3C School

Source: Internet
Author: User
ArticleDirectory
    • Window object
    • Navigator object
    • Screen Object
    • History Object
    • Location object
Window object

Window object indicates the window opened in the browser. If a document contains a frame (frame or IFRAME tag), the browser creates a window object for the HTML document and creates an additional window object for each frame.

Window object set

Window Object Attributes

Window object Method

 

 

Navigator object

The navigator object contains information about the browser.

Navigator object set

Navigator Object Attributes

 

 

Screen Object

The screen object contains information about the client display screen.

Screen Object Attributes

Screen Object Description

The screen attribute of each window object references a screen object. The screen object contains information about the browser screen. JavascriptProgramThe information will be used to optimize their output to meet the user's display requirements. For example, a program can choose whether to use a large image or a small Image Based on the display size. It can also choose whether to use a 16-bit color or an 8-bit Color Image Based on the display color depth. In addition, the Javascript program can locate the new browser window in the middle of the Screen Based on the screen size information.

 

 

History Object

The history object contains the URL accessed by the user (in the browser window.

History Object Attributes

History Object Method

History Object Description

The history object was originally designed to indicate the browsing history of the window. However, for privacy reasons, the History Object no longer allows scripts to access actual URLs that have already been accessed. Only the back (), forward (), and go () methods are supported.

 

 

Location object

The location object contains information about the current URL.

Location Object Property

Location object Method

Location Object Description

The location object is stored in the location attribute of the window object, indicating the web address of the document currently displayed in that window.

The href attribute stores the complete URL of the document, and other attributes describe each part of the URL. These attributes are very similar to the URL attributes of the anchor object (or area object. When a location object is converted to a string, the value of the href attribute is returned. This means that you can use the expression location to replace location. href. However, the anchor object represents the hyperlink in the document, while the location object represents the URL (or location) of the document currently displayed by the browser ). However, the location object can do much more than this. It can also control the location of the document displayed by the browser. If you assign a URL-containing string to the location object or its href attribute, the browser will load the document referred to by the new URL and display it.

In addition to setting location or location. href to replace the current URL with the complete URL, you can also modify some URLs by assigning values to other attributes of the location object. In this way, a new URL will be created, and some of them are different from the original URL. the browser will load and display it. For example,Assuming that the hash attribute of the location object is set, the browser will transfer to a specified location in the current document. Similarly, ifSearch attributesThen, the browser will re-load the URL with the new query string appended.

in addition to the URL attribute, the reload () method of the location object can reload the current document. Replace () can load a new document without creating a new history for it, that is to say, in the browser's history list, the new document replaces the current document.

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.