JavaScript-BOM (browser object model), interval and pause

Source: Internet
Author: User

JavaScript-BOM (browser object model), interval and pause
BOM (Browser object model): allows you to access and operate windows in the browser.
1. Basic BOM system:
Window ------------ document -------------------------------------------- anchors
|
-- Frames ---- forms
|
-- History ---- images
|
-- Location (browser address) ---- links
|
-- Navigator (obtain browser information) ---- location
|
-- Screen)
2. screen Object: access through the window. screen attribute
(1) availHeight/availWidth (return the inner height/width of the screen, which does not change with the window size relative to the hardware)
(2) height/width: Return to the total height of the screen hardware, which cannot be changed
(3) pixelDepth display screen color resolution (bit per pixel)
3. location object: access through the window. location attribute
(1) set or return the URL (Anchor) starting with the # In hash ).
(2) set or return the host name and the port number of the current URL.
(3) set or return the Host Name of the current URL.
(4) href sets or returns the complete URL.
(5) set pathname or return the path of the current URL.
(6) port sets or returns the port number of the current URL.
(7) protocols set or return the protocol of the current URL.
(8) search sets or returns the question mark (?) The start url (query part ).
(9) assign () loads new documents
(10) replace () replace the current document with a new document
For example: window. location. replace ("http://www.w3school.com.cn ")
(11) reload () reload the current document
4. history Object: accessed through the window. history attribute
(1) length: return the number of URLs in the browser history list.
For example, document. write (history. length );
(2) back () loads the previous URL in the history List
(3) forward () loads the next URL in the history List
(4) go () loads a specific page in the history list
5. navigator object:
(1) String Representation of the appCodeName browser code name (for example, "Mozilla ")
(2) String Representation of appName official browser name
(3) String Representation of additional appMinorVersion Information
6. Time Interval and pause
Pause: Execute the Specified Code after a specified number of milliseconds. The interval is to repeatedly execute the Specified Code, waiting for the specified number of milliseconds between each execution.
Use the setTimeout () method of the window object to set the pause and accept two parameters. The code to be executed and the number of milliseconds to wait before it is executed can reference previously defined functions, for example, setTimeout (func, 1000). It means to execute the func function in 1 second.

Difference between setTimeout and setInterval:

The setTimeout method is a Timer Program, that is, after what time. It's all done.
The setInterval method indicates that an operation is executed repeatedly at a certain interval.
Set latency in JS:
SetInterval is similar to setTimeout. SetTimeout is used to perform an operation after a delay period.
SetTimeout ("function", time) sets a timeout object
SetInterval ("function", time) sets a timeout object
SetInterval indicates automatic repetition, and setTimeout does not.
ClearTimeout (object) clears the set setTimeout object
ClearInterval (object) clears the set setInterval object


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.