Javascript Book
Javascript Book
Javascript Book
W3Schools
www.w3schools.com
apc1424@yahoo.com
* W3Schools
........................................................ ....................................................... . ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ...................... .................................. ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................ ........................................................
. Netscape . Navigator Internet Explorer .
!
: WWW HTML . . www.w3schools .com
.HTML . . - .HTML . . .
Java
! ... ) ( C ++. C
HTML HTML ! HTML . HTML )">1 document.write("<h1>"+name+"</h .HTML .HTML HTML .HTML - .Servers
! )( HTML ... FrontPage HTML ... Note Pad file.htm file.html IE .Navigator
IE
HTML
:
><html ><body >"<script type="text/javascript )"!document.write("Hello World ></script ></body ></html : HTML
ex1.html :
!Hello World
: document.write
)"!document.write("Hello World
><script
></script
++ C )( " ; ".. ! .
. - HTML HTML :
>"<script type="text/javascript -!<some statements >--// ></script
)//( . : // ) --!<// ( .
: ...
body ... ) (. head ... :HEAD functions head . . :BODY .body : .External File
. . : head head .
><html ><head >"<script type="text/javascript some statements ></script ></head
:body ) ( .
><html ><head ></head ><body >"<script type="text/javascript some statements ></script ></body
. . ) .js: (file.js :
)"document.write("This script is external
"" . ) ( . . : case sensitive Book book bOoK... _ . underscore : var
var strname = some value
:var
strname = some value
:
"var strname = "Ahmed
:
"strname = "Ahmed
. :
2=x 2+x 2=x 5-x 4=x 5*x 5/51 2/5 2%5 8%01 2%01 5=x ++x 5=x --x
+ * / % ++ --
... ...
...
x=y x=x+y x=x-y x=x*y x=x/y x=x%y
= =+ =- =* =/ =%
6=x 3=y )1 > (x < 10 && y )( 6=x 3=y )5== (x==5 || y )( 6=x 3=y ) !(x==y )( ) not( ! ) or( ||
) and(
&&
) ( event . : ) head( . :
)"alert("This is a message
argument .
)function myfunction(argument1,argument2,etc { some statements }
:
)(function myfunction { some statements }
. . head . :
)function result(a,b { c=a+b return c }
. :
)myfunction(argument1,argument2,etc
:
)(myfunction
return . return . : :
)function total(a,b { result=a+b return result }
) ( :
)3,2(sum=total
5 . . sum
) ( . : if ) .(true ifelse . switch . If Ifelse if - ) (false .
)if (condition { code to be executed if condition is true } ) : (Good Morning >"<script type="text/javascript ,01 //If the time on your browser is less than .//you will get a "Good morning" greeting )(var d=new Date )(var time=d.getHours )01<if (time { )">document.write("<b>Good morning</b } ></script
else ) ( ) (. . Ifelse
Ifelse
if (condition) { code to be executed if condition is true } else { code to be executed if condition is false } Good Morning ! ) : ( Good day! <script type="text/javascript"> //If the time on your browser is less than 10, //you will get a "Good morning" greeting. //Otherwise you will get a "Good day" greeting. var d = new Date() var time = d.getHours() if (time < 10) { document.write("Good morning!") } else { document.write("Good day!") } </script>
Switch .
switch (expression) { case label1: code to be executed if expression = label1 break case label2: code to be executed if expression = label2 break default: code to be executed if expression is different from both label1 and label2 }
.
2variablename=(condition)?value1:value
" greeting=(visitor=="PRES")?"Dear President ":"Dear
: visitor PRES " "Dear President greeting visitor PRES " "Dear .greeting
. : while . dowhile . for . while ) ( :
)while (condition { code to be executed }
dowhile .
do { code to be executed } )while (condition
for .
)for (initialization; condition; increment { code to be executed }
Date Object Math Object .Array Object Date Object ) (. " "new . : my_date
)(var my_date=new Date
methods .my_date :
)(my_date.getDate
:
new new new new new )"Date("Month dd, yyyy hh:mm:ss )"Date("Month dd, yyyy )Date(yy,mm,dd,hh,mm,ss )Date(yy,mm,dd )Date(milliseconds
:
var var var var var my_date=new my_date=new my_date=new my_date=new my_date=new )"00:41:31 8891 ,21 Date("October )"8891 ,21 Date("October )00,41,31,21,90,88(Date )21,90,88(Date )005(Date
": "r_number
)6.8(r_number=Math.round
: E ) abs(x .x
:
myfunction myFunction . )( )} ] " ' ' " [ { ( . . :
"name="Hege "name = "Hege
\ . :
\ document.write("Hello )"!World
: :
\ document.write )"!("Hello World
:
."You & I sing "Happy Eid
// :
sum=a + b //calculating the sum
:
/* This is a comment block. It contains /*several lines
: ><script Script Block ></script Variable true/false . Initialize . Call Function . . Argument Expression . . Statement . Statement Block For For Loop . While While Loop . Conditional . Branching Multi-way Branching default Return .
JavaScript in easy steps .
:
) ( ) ( "" .Code ) ( ) ( ) - ( ... Loops . )( )( " ". ) ( apc1424@yahoo .com .W3Schools
apc1424@yahoo.com W3Schools