Complete parsing of BOM objects in js

Source: Internet
Author: User
BOM is the browser object model. It includes the following objects! (1) The screen Object contains information about the display browser Screen. Common attributes: availHeight: return the height of the display screen avai

BOM is the browser object model. It includes the following objects!

(1) The screen Object contains information about the display browser Screen.

Common attributes include:

AvailHeight: returns the screen height.

AvailWidth: returns the width of the display screen.

ColorDepth: returns the bit depth of the palette on the target device or buffer.

Height: returns the actual height of the screen area.

Width: returns the actual width of the screen area.

 

(2) Window object, which indicates a browser Window or a framework.

Common Methods:

(1) Opening and closing windows:

Window. open (URL, name, features, replace), all of which are optional parameters

URL: the URL of the document displayed in the new window

Name: Declares the name of the new window.

Features: Declares the features of the standard browser to be displayed in the new window.

Replace: Boolean value. true-URL replaces the current entry in the browsing history. False-the URL creates a new entry in the browsing history.

 

Window. close () close the current window

 

(2) Change the position and size of the window:

The moveTo (x, y) method moves the upper left corner of the window to a specified coordinate.

The moveBy (x, y) method moves the specified pixel relative to the current coordinate of the window.

The resizeTo (width, height) method is used to adjust the window size to the specified width and height.

The resizeBy (x, y) method is used to adjust the window size based on the specified pixels.

 

(3) In the status bar, you can set the status attribute and defaultStatus attribute of the window object to change the basic information displayed in the status bar.

For example, window. defaultStatus = "php point-to-point ";

 

(4) timed setting. The timer can execute specific functions within a specific period of time.

The setTimeout (epress, time) method is used to call a function or computing expression after a specified number of milliseconds.

ClearTimeout (timeID) stops a started Timer

The script is as follows:


Script function timer () {var t = setTimeout ("alert ('5 seconds to ')", 5000);} script

 

The setInterval () method can call functions or computation expressions according to the specified period (in milliseconds.

ClearInterval () stops using the setInterval () method

The script is as follows:


Script var timer; function start () {var date = new Date (). toLocaleString (); window. status = date;} script

(5) The Navigator object contains properties that describe the browser in use

AppName: return the browser name.

AppVersion: returns the platform and version information of the browser.

Platform: returns the operating system platform that runs the browser.

AppCodeName: return the code name of the browser.

 

(6) The History object is actually used to save the browser History information.

Its attributes include length, which returns the number of URLs in the browser's Historical List.

The methods include:

Back () loads the previous URL in the history list.

Forward () loads the next URL in the history list.

Go () loads a specific page in the history list.

For example, a common Previous Page is returned: History. go (-1) and history. back ()

 

(7) Location object. Location object is a part of the Window object and can be accessed through the window. location attribute.

Method:

Hash: set or return the URL (Anchor) starting with ).

Host: set or return the host name and the port number of the current URL

Hostname: set or return the Host Name of the current URL.

Href: set or return the complete URL.

Pathname: Specifies or returns the path of the current URL.

Port: set or return the port number of the current URL

Protocol: set or return the protocol of the current URL.

Search: sets or returns the question mark (?) The start url (query part ).

Method:

Assign () loads new documents.

Reload () to reload the current document.

Replace () replaces the current document with a new document.

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.