JS Basic knowledge

Source: Internet
Author: User

JavaScript Event List

General Events : mainly mouse erase even

page Events : OnLoad (This event is triggered when page content finishes), OnMove (browser window is moved), OnResize (browser window size changed), OnStop (The browser stop button is pressed or the file being downloaded is interrupted), Onabort (interrupted by user at download)

form Event : onsubmit (Submitted when form event is triggered)

JavaScript Common internal objects

Object provides custom objects and does not need to define constructors

String dynamic object to reference its properties and methods only after the instance is created

-----------------length, indexOf, replace, substr (returns the specified position, specified length), substring (returns all strings from one start position to another ending position), toLowerCase, toUpperCase

Array creates arrays that can be sorted, deleted, and so on

Document This object is an object that works with the documents element

----------------Write, Writeln (similar to write, but output text is then empty), open (clears the current document, writes to the specified type of data stream), close (closes the document input stream)

1, Timer related knowledge

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=gb2312" /><title>Untitled Document</title> </Head><Bodyonload= "progress_update ()"><DivID= "Demo"style= "Border:solid #0000FF 2px"></Div><Scripttype= "Text/javascript"> varProsressinterval= -; varProgressbegin=0; varProgressend= -; varProgresstimer;functionprogress_clear () {//emptying the timercleartimeout (Progresstimer); //Hide Divdocument.getElementById ("Demo"). Style.visibility="Hidden"; } functionprogress_update () {Progressbegin++; if(Progressbegin>progressend)//progress_clear ();cleartimeout (Progresstimer); Else        //document.getElementById ("Demo"). style.backgroundcolor= "Blue";document.write ("<br>"+Progressbegin+" "); Progresstimer=SetTimeout ("progress_update ()", Prosressinterval); }</Script></Body></HTML>

2. Function-related knowledge

This example is mainly about creating the properties, methods, and methods of the student class.

var obj=new objname (parameter);

For (var. student) {alert (flag+property+ "" +student[property]);}

Use the above methods to view the properties and methods in student

<!DOCTYPE HTML><Head></Head><Bodyonload= "progress_update ()"><DivID= "Demo"style= "Border:solid #0000FF 2px"></Div><Div><inputID= "Txt1"type= "text"  /><inputID= "Txt2"type= "text"  /><inputID= "BUT1"type= "button"onclick= "Study ()"  /></Div><Scripttype= "Text/javascript">//Custom Functions//function Name (parameter)//{Code;return expression;}//Creation of ObjectsfunctionStudent (name,age) { This. Name=name; This. Age=Age ; This. Read=read;//Note Call Method Read () This usage}functionRead () {alert ( This. Name+"is reading a book");}functionStudy () {varStudent=NewStudent (txt1.value,txt2.value); Student. Read ();} </Script></Body></HTML>

Attention:

1, to focus on the basic use of string

2. The timer is likely to be used

3, document.write ("content"), document.getElementById ("id")

4. JS is case-sensitive, the annotation and basic grammar are the same as the C-system language.

the difference between innerhtml,innertext,value in JS

JS Basic knowledge

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.