Python Learning (22)-The BOM and Dom of the front-end base

Source: Internet
Author: User

Reprinted from Http://www.cnblogs.com/liwenzhou/p/8011504.html

First, preface

So far, we've learned some simple syntax for JavaScript. But these simple grammars do not have any interaction with the browser.

That is, we are not able to make some interactions with the pages we often see, and we need to continue to learn about BOM and Dom.

JavaScript is divided into Ecmascript,dom,bom.

The BOM (Browser object model) refers to the browser window object models, and the top-level object is window.

The DOM (Document Object model) refers to the text of the documents, not an object.

window, document is an instance object, and they all belong to object, which represents the windows opened in the browser.

The Window object is one of the top-level objects of the client-side JavaScript, and since the Window object is a common ancestor of most other objects, the Window object's reference can be omitted when invoking the methods and properties of the Window object. For example: Window.document.write () can be simply written as: document.write ().

Second, Window object

The Window object represents a browser window.

In client-side JavaScript, the Window object is a global object, and all expressions are evaluated in the current environment. In other words, to refer to the current window does not require a special syntax, you can use that window's properties as a global variable. For example, you can write only document without having to write window.document

Similarly, the method of the current Window object can be used as a function, such as write only alert (), without having to write Window.alert ().

Alert ()            displays a warning box with a message and a confirmation button. SetInterval ()      invokes a function or evaluates an expression by the specified period (in milliseconds). Clearinterval ()    cancels the timeout set by SetInterval (). SetTimeout ()       invokes a function or evaluates an expression after the specified number of milliseconds. Cleartimeout ()     cancels the timeout set by the SetTimeout () method. ScrollTo ()         scrolls the content to the specified coordinates. Confirm ()          displays a dialog box with a message along with a confirmation button and a Cancel button. Prompt ()           displays a dialog box to prompt the user for input. Open ()             opens a new browser window or looks for a named window. Close ()            closes the browser window.

A few examples:

// The corresponding function is executed once every once in a while var timer = setinterval (function() {console.log (123);}, +)//  Cancel setinterval Settings clearinterval (timer); // executes the corresponding function once after the specified time var timer = setTimeout (function() {alert (123);}, +)//  Cancel settimeout Settings cleartimeout (timer);

Third, the child object of Window 1.navigator object

A browser object that can be used to determine the browser the user is using, including information about the browser.

Navigator.appname //  Web browser full name navigator.appversion //  Web browser vendor and version detailed string Navigator.useragent //  client Most information navigator.platform //  the operating system where the browser is running
2.screen objects

Screen objects, not commonly used.

3.history objects

The browsing History object contains the user's browsing history of the current page, but we cannot view the specific address that can be used to forward or rewind a page.

History.forward ()  //  forward one page history.back ()  //  back one page history.go (n)  //   forward N page
4.location objects
location.href  Get urllocation.href//  jump to the specified page location.reload () reload page

Python Learning (22)-The BOM and Dom of the front-end base

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.