Edited by: Phạm Thuận Hiếu Ref:w3schools.com JAVASCRIPT Browser scripting
What is JS? -1 Scripting language Interacted Embedded Interpreted A sequence of statements Free JavaScript = ECMAScript (ECMA- 262)
What is JS?-2
We have to study JS. Why? Easy to learn. Easy to practise. Working in all major browsers We had a good knowledge of: HTML, CSS, through the previous seminar. So JS is the next step. It’s very amazing. Trust me!
Tools Any editors such as: Notepad, Wordpad... I use Notepad++ to illustrate all samples. When we have a large of statements: Use JSLint: assume, alert... Use Microsoft Script Debugger: control, execute, debug
Content What is JS? We have to study JS. Why? Tools Where script can be placed? JS practise
Where script can be placed? In, (Use one or some tags) In external files. (NOT contain the tags) Example:
JS Syntax-1-Variables var x; var y=0; var Y;/*comments*/ var z=“Hello”; var t=y;//comments var p = y+5; var q = p%2; var r = q/=2; var i=z+” “+”World!”; Local Global
JS Syntax-2-Comparisons&Operators + - * / % = += -= *= /= %= == != > = && || ! Ternary operator ===
JS Syntax-3-Statements If...else Switch...cases Loop: for, while, do..while, for in Popup box: alert(“text”);//alert box confirm(“text”);//confirm box prompt(“text”,”defaultvalue”);//input value before //entering a page.
JS Syntax-4-Functions & Events Define a Function function functionname(var1,var2,...,varX) { //some code //return value } Events are actions that can be detected by JavaScript. RefRef
JS Syntax-5-Timing Events Use 2 methods: setTimeout & clearTimeout Syntax: var t=setTimeout("statement",milliseconds); clearTimeout(setTimeout_variable)
JS Objects ObjectMethods & attributes Stringlength, match(), replace(),...RefRef DategetDay(), getTime(),...RefRef Arrayjoin(), pop(),...RefRef BooleantoString(), valueOf()RefRef Mathround(), random(), max()...RefRef RegExpRef
JS Advanced & Practise JavaScript Advanced: next seminar. Now, let’s explore all basic examples.explore