JavaScript Object--------------and you know that

Source: Internet
Author: User

What I'm bringing to you today is some of the properties and functions of the JavaScript object that we can use to make those page effects, and here's the topic for today.

1. Complete JavaScript is composed of ECMAScript, BOM(Browser object model), and DOM(Document Object model). As follows:

While the Window object is the core of the entire BOM, the Window object is one of the top-level objects of the client-side JavaScript, as long as you open the browser window, regardless of whether there are open pages in the window, when you encounter BODY,FRAMESET or FRAME Element, an instance of the Window object is automatically created. Also, an instance of the object can be created by the window.open () method. Because the window object is a common ancestor of most other objects, you can omit a reference to the Window object when invoking the methods and properties of the Window object. The following is a BOM model diagram:

Here we focus on the common properties and methods of the Window object and the History,location and document objects underneath it.

The first is the Window object,

Property:

Name Description
History Information about URLs that customers have visited
Location Information about the current URL

Method:

Example: (Picture switching using setinterval ()

varnum = 1; Window.onload=function () {            functionemp () {if(Num < 3) {num++; } Else{num= 1; }                varDom = document.getElementById ("MYIMG1") alert (DOM); DOM.SRC= "image/" + num + ". png"; } setinterval (EMP,1000); }    </script>

With this simple way to change the value of the SRC attribute of the image every second, the effect of the image switching is realized.

The following are common events for window objects

Next I'll introduce the history and location objects

The History object first provides a list of URLs that the user has recently browsed.

They can implement the forward and backward functions of the page

The following are the common properties and methods of the Location object

It can implement page refresh (reload ()) and the href attribute used in hyperlinks.

Here is the key document object

These methods can lock tags to change some properties for special effects.

As the above image rotation is used (getElementById () to change the SRC attribute of img to achieve picture rotation)

The following timer also uses this method:

varT1; Window.onload=function () {            varStart = document.getElementById ("Mystart"); varStop = document.getElementById ("Mystop"); Start.onclick=function() {T1= SetInterval (step, 1000); } Stop.onclick=function() {clearinterval (T1); }        }                       functionStep () {varDom = document.getElementById ("num"); varnum =Dom.innertext; if(num>0) {num--; } Dom.innertext=num; }    </script>

In JavaScript, let me introduce the system's built-in objects--------date objects

With these methods we can make a walking clock effect.

All right, so much for today, next time I see!!!!!!!.

JavaScript Object--------------and you know that

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.