JavaScricp, javascri
JavaScript syntax
The basic data type is basically the same as that of C #. The omnipotent variable var can store other types of values and can be directly used.
Explicit conversion:
Parseint () -- convert to an integer
Parsefloat () -- convert to decimal
Operator: Same as C #
Mathematical operators: +-*/% + + --;
Relational OPERATOR: =! ==>=<=;
Logical OPERATOR: & | !;
Other operators: + =-= * =/= % =? :
Branch statement:
If... else
Loop statement:
For ()
Array:
New Array (); -- fixed type, Unfixed Length
Array attribute: a. length; number of array elements
JavaScript is a scripting language
Common Dialog Box:
- Alert () -- warning dialog box to pop up a warning dialog box
- Confirm () -- returns True or false with the OK or cancel buttons
- Prompt () -- a dialog box that can be entered is displayed.
Function:
Function Name (parameter ){}
Function () {}-- anonymous function
Window object:
- Window. open ("open URL" "open Location ")
- Window. opener -- open the previous page on this page
- Window. close () -- close the current page
- Window. navigate ("url") -- hyperlink Function
- Window. moveTo (x, y) -- move the browser to a certain position
- Window. resizeTo (x, y) -- set the width and height of the browser
- Window. scrollTo (x, y) -- anchor Function
Timer:
- Window. setTimeout (function () {}, interval of execution time) -- how long will it be executed? only once
- Window. setInterval (function () {}, interval execution time) -- The interval at which execution is performed and does not stop
Window. history:
- Window. history. back () -- return the page
- Window. history. forward () -- page forward
- Window. history. go (n) -- forward and backward. If n is positive, the system advances to n pages. If n is negative, the system returns to n pages.
- Window. location. href = "url" -- hyperlink, mainly
- Window. status -- objects in the toolbar at the bottom of the Operation page
Window.doc ument:
- Docunment. getElementById ("id"); locate by id. You can find one at most;
- Docunment. getElementsByName ("name"); find the array by name;
- Docunment. getElementsByTagName ("name"); find the Tag name and find the array;
- Docunment. getElementsByClassName ("name") is searched based on classname and an array is found;