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

Source: Internet
Author: User

JavaScript-BOM (browser object model), interval and pause, bom Object Model
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



Urgent. Question about the javascript Object Model?

One point is worth noting: bom dom is an implementation of browser vendors in their own products based on unified standards. At the same time, each browser will add some of its own unique features. This is why ie has the document. all attribute but Firefox does not.

What do you mean about onclick? In fact, js requires this interface and the browser is required to support the onclick feature, so both ie and ff implement onclick, therefore, they belong to browsers and all follow the js standards. In fact, the implementation of the event mechanism in ie and ff is also different, but the functions are mostly unified with standards.

Your last statement is correct.

In a hurry, ask the javascript Object Model question?

1. Although bom has never heard of it before, it is absolutely not only ie that can access browser information. As long as javascript is supported, browser information is provided.
If you traverse the window object of ie, you will find two objects that save the information of the browser, which are not found in other browsers.
Window. open is part of the dom, which is also supported by all browsers.

2. dom certainly does not belong to bom, but bom is similar to dom, and dom is supported by all browsers, but to a different extent, ie is the worst supported.

3. javascript is almost impossible to change the browser or anything. It can only read the information of the browser.

4. unclear

5. This code is not properly written in html. If it is js, a dialog box will pop up immediately, and the event listener should be undefined.
The default onclick language must be javascript.

Bom and dom are not limited to one language. They are supported in multiple languages, and dom operation functions are also available in php.

Finally, dom definitely does not belong to bom.

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.