ECMAScript
JS Simple Introduction (the difference from Java)
1. Syntax (case sensitive, weak type, semicolon writable, not writable)
2. Variable (can only use the var definition, or not defined, if you use the var definition inside the function, then it is a local variable, if not using Var, it is a global variable)
3. Data type (undefined defined no assignment/null variable does not exist/string/number/boolean)
4. Statement: with keyword
var smessage = "Hello"; With (smessage) { alert (touppercase ()); Output "HELLO" }
5. Operator: = = and = = = Difference (= = is the same, data type can be different, = = = is strictly the same, if different is false)
if ("==120") Alert ("Equal")
if ("===120") alert ("Exactly equal")
The first print is equal, the second one does not print
6. Functions: 2 Ways of writing (with name, anonymous)
The arguments object, arguments is an array name for the passed parameter, Arguments[0] represents the first argument, 1 indicates the second, and so on
function (slightly) closure, referencing global variables
BOM Object
Window:alert (hint info), Prompt (Popup input box), confirm (confirmation message), setinterval (function, time)
Infinite execution, clearinterval (timer name), SetTimeout (function, time) only executes once, cleartimeout (timer name)
History:go (parameter)-1 means previous page, 1 means next page, back () Return to previous page, forward () return to next page
location:href= "URL Address"
Event
OnSubmit () This event must be written in the Form tab, must have a return value, confirm that the button is clicked
OnLoad () This event can only be written once, and placed in the body tag, a page or an image to complete loading.
<HTML> <Head> <Scripttype= "Text/javascript"> functionload () {alert ("Page is loaded") } </Script> </Head> <Bodyonload= "load ()"> </Body> </HTML>
Other events are placed where the element is to be manipulated (Onclick,onfocus (get Focus), onblur (loses focus))
Dom Object
Get element:
document.getElementById ("id")
Gets the value inside the element:
document.getElementById ("id"). Value
Output to page: alert ();
Write content to Browser: document.write ("")
Writes to the page at the specified location, InnerHTML
Basic Introduction to JavaScript knowledge