You are on page 1of 70

JAVASCRIPT LERNNING

:
.
By :
Eng . SAMI AL-RABAAH

Email :
e_book@myway.com


Feb 2004

) ( switch ) & ( if condition

) ( for & While & Do while

) ( function

) ( Arrays

) ) ( Object (Math & Date & String

) (

: : JAVASCRIPT


forms

.
Netscape
Sun



for loop if condition



...

HTML



..


NOTEBAD
.

JAVA JAVASCRIPT
DHTML DHTM JAVA SCRIPT


JAVASCRIPT DHTML
.. JAVASCRIPT
JAVA DHTML JAVA
JAVASCRIPT DHTML JAVA DHTML
JAVASCRIPT DHTML JAVA
.
JAVASCRIPT
.




..
.
Object
. .Object.

JAVASCRIPT

OOP
++

.

Keywords .


:
do
if
switch
voide

delete
function
return
var

continue
for
null
typeof

case
false
new
true
with

breake
else
in
this
while


.





.



dir = rtl
html .
: Notepad

word

.

..
- :
>"<script type = " text/javascript

></script

- :
>"<script language="JavaScript

></script

) ( notepad
.

..

) ( html :
) >( <head> ----------- </head
:
..

:
><html
></title ><head><title
>"<script type = " text/javascript

></script
></head
><body></body
></html

..
- :
: ) ... ( html
;)" "(document.write

: ) ... ( html
;)"> </h1 >document.write("<h1

: ) ( htm ) ... ( style


;)"> </h1 >"\document.write("<h1 style=\"color : red

: ...
;) document.write( sum

: ..
;) " + sum document.write(":

: ..
;)" " " + sum + document.write(":

:
o ) " (
)(html
o .... :
- ... ) " (.
- ) " (
) ( " + ) ( +
....
... ) ( +
;) " + sum document.write(" :

... ) ( +
;) " document.write( sum +" :

... ) ( + ..
;)" " " + sum + document.write(":

) ( +
) ( +

..
o ) (document.writeln ) (document.write
" " ..
o " " )> (<br /
..
:
;)" document.write(" Arab <br />Top

:
Arab
Top
...
- .Window Object
:

) ( alert ...
;)" "(window.alert

* ) :( alert

\n
\t
\r
\\
"\
'\




position
) \ (
) " (
) ' (

..
;)"window.alert("hi \n all
;)"window.alert("hi \t all
;)"window.alert("hi \r all
;)"window.alert("hi \\ all
;)"window.alert("hi \" all
;)"window.alert("hi \' all

- " "
. Window Object
:

) ( prompt ...
;)" "", "( window.prompt

:
) ( prompt ..

...
Window Object
;) "(var con = confirm

:
:

...
) .( var

:
; var name

) " ( integer Or float


" :
; ) ( 1- parseInt
) ( integer :
; var number = 55
; )parseInt (number

; ) ( 2- parseFloat
) ( float :
; var number = 5.4
; )parseFloat (number

:
) . ( parseFloat
.. .
...
:
>"<html dir="rtl
></title ><head><title
><script
; var name
; ) "" " , " ( name = window.prompt
; ) " + name " (document.write
></script
></head
><body> </body
></html

:
) . ( name

) . ( window.prompt
) ( name :
; ) "" ", " ( name = window.prompt

) ( name :
; ) " + name " (document.write

.
" " ...
" "
" " :
:
><html
></title ><head><title
> "<script type = "text/javascript
; )" "( window.alert
></script
></head
><body></body
></html

) ( alert ..

+
*
/
%

x+y
y x
x*y
x/y
x%y

x+y
xy
X*y
x/y
x%y

>
<
=>
=<

==
=!
>
<
=>
=<

x == y
x != y
x>y
x<y
x >= y
x <= y

x y
x y
x y
x y
x y
x y

:
.
:
; var number = 4
; number+ = 2

) ( number ) ( 4 ) ( 2 ) .( 6
:
; var number = 4
; number= number+ 2

....
:
; var number = 4
;number * = number

) ( number ) ( 4
) ( 4 ) .( 16

:

.. ) ( True
) ( False .

.

- ) : ( if

.
:
) ( If
{

}

:
>"<html dir="rtl
></title ><head><title
>"<script type ="text/javascript
;"var pass_2="okman
;var pass_user
;)" "", "(pass_user = window.prompt
)if (pass_2 == pass_user
{
; )" "( document.write
}
></script
></head
><body></body
></html

) ( pass_2 ) ( okman
) ( pass_user

) ( pass_user ) ( if
) ( pass_2 ) ( pass_user
) ) ( if ( pass_2==pass_user ) ( pass_2
) ( pass_user ..

... ..
" " ..
- ) : ( if / else
:
:

.
:
) ( else
.
:
) ( If
{

}
else
{

}

..
:
<html dir="rtl">
<head><title>< /title>
<script type ="text/javascript">
var pass_2="okman";
var pass_user;
pass_user = window.prompt(""";)"
if (pass_2 ==pass_user )
{
document.write (" ; ) "
}
else
{
document.write (" ; )"
}
document.write (" ; )"
</script>
</head>
<body></body>
</html>

) ( pass_2 ) ( okman
) ( pass_user

) ( pass_user ) ( if
) ( pass_2 ) ( pass_user
) ) ( if ( pass_2==pass_user ) ( pass_2
) ( pass_user ..

... ) ( else ..
) ( if
..
..
..
" "..

) : ( if

- ) ( nested if
.
:
>"<html dir="rtl
></title ><head><title
>"<script type ="text/javascript
;"var name1 ="sami
;"var name2 ="mahmoud
)"if (name1 =="sami
)"{ if (name2 =="mahmoud
; ) " "( document.write
}
; ) " "( document.write
></script
></head
><body></body
></html

)
( ...

:
) ( .
;) " If ( name1 == " sami

) (
:
;)" if ( name2 == " mahmoud

. .
.

) ( if ) ( if ) ( if
.
...
) ( if .

) : ( switch


.. ) ( if ..
) ( switch :
:
{ ) ( switch
; case :

; case :

; case :

.
.
.
default :
.. case ..
" " }

.. ..
.
:
>"<html dir="rtl
></title ><head><title
>"<script type = "text/javascript
; var country
;)" ", "0 " (country=window.prompt
{ ) switch ( country
" : " case
; )"></h3 >document.writeln("<h3
; breack
" : " case
; )"> </h3 >document.writeln("<h3
;breack
" : " case
; )"> </h3 >document.writeln("<h3
; breack
" : " case
; )"> </h3 >document.writeln("<h3
; breack
; )"> </h3

default :
>document.writeln("<h3
}
></script
></head
><body></body
></html

) : ( case

:
) ( country ) ( window.prompet
...
) ( switch :
) switch ( country

) ( case
:
" : " case

) ( case
) ( switch ) ( case
) ( break , "
) ( break " .
) ( default
) ( case
) ( default ) { (
.
) ( prompt
) ( switch
) switch ( country

) ( switch ) ( case :
; " " case

. ) ( case ...

) ( case ) = (
) ( case :
; )" > </h3 >document.writeLn( "<h3

" : "
) ( break ) ( switch
) ( case .
... ) ( default :
; )" > </h3 >document.writeln( "<h3

) ( switch
) ( true
) ( true ) ( false
) ( default ) ( case
) ..( false ) .( default

:

.

. . .

.
.
:
- ): ( for

.
:
) ; ; ( for
{

: ) (
:
> <html
></title ><head><title
>"<script type = "text/javascript
) for (var i = 0 ; i<= 10 ; i ++
{
; ) document.write ( i
}
></script
></head
><body></body
></html

: i
...

:
) (i
) (i=0 ). (0
) ( i < = 10
) ( i ) ( 10 ) ( 11
) ( i ) . ( 10
.
) ( i ) ( 1 .
* " " :
:
) for ( var i = 0 ; i < = 10 ; i ++

) ( i ) . ( 0
) ( i < = 10 ) ( i ) ( 10
.
) ( i++ ) ( for
) ( i ) . ( 1
) ( i ) ( 0 ) ( for ) ( i
) ( 1 ) .( 1
) ( i ) ( 1
) . ( 0

:
) ( 1 ) ( 10 ) ( 1 ) . ( 10
) ( i++
) ( for ) ( i ) ( 1 ) . ( 2
) ( for ) ( i " " ) ( 2
) ( 11 :

) ( i ) ( 11 ) ( for
) ( i < = 10 ) ( i ) ( 11 ) ( 10
.
. . .

) ( for
.
.
:
> <html
></title ><head><title
>"<script type = "text/javascript
) for (var i = 1 ; i <=10; i ++
{
; ) document.write ( i
}
;)" >document.write (" <br /
></script
></head
><body></body
></html

: ...
) ( i ) ( 1 ) ( i
) ( 10
) (
:

=2
=3
=4
=5
=6
=7
=8
=9
=10

i
i
i
i
i
i
i
i
i

++
++
++
++
++
++
++
++
++

i
i
i
i
i
i
i
i
i

=1
=2
=3
=4
=5
=6
=7
=8
=9

i
i
i
i
i
i
i
i
i

i = ' 10 ' i ++ i =11

) ( 10 ) ( i
) ( i ) ( 11 ) ( 10
" "
;) >document.write ( " <br /

12345678910

...
) ( 10 ) ( 0
:
> <html
></title ><head><title
>"<script type = "text/javascript
)for (var i =10 ; i>=0 ; i--
{
; ) document.write( i
}
)" >document.write ( " <br /
></script
></head
><body></body
></html

10987654321

' ' reverse .

) : ( While



while .
:
) ( While
{

i ++
}

) ( while :
- .
- ) . ( while
-
.

:
> <html
></title ><head><title
>"<script type = "text/javascript
; var i = 1
) while (i <= 10
{
; ) document.write ( i
; i ++
}
></script
></head
><body></body
></html

:
) ( i ) ( 1 ) . ( i <= 10
) ( while ) ( i ) ( 10
) ( 1 ) ( 10
...
) While ( 1 <= 10

) ( i ) . ( 1
; ) document.write ( i

) ( i++ ) ( i ) ( 1 ) ( i
) .( 2

) ( while ) ( i ) ( 10
) ( while ) ( i ) ( 1 ) . ( 2
) While ( 2 <= 10

) ( i ) . ( 2
) " ( i++ ) ( i ) ( 1 ) ( i
) ( 2 ) . " ( 3
) ( while ) ( i ) ( 3
10 ) ( i ) ( 11 :
) ( while ) ( i ) ( 11 ) ( 10
.
.
) ( .
) ) ( while ) . . ( ( for
) : ( 1
> <html
></title ><head><title
>"<script type = "text/javascript
; var i = 10
) while (i>= 1
{
; ) document.write ( i
; i --
}
></script
></head
><body></body
></html

) : ( Do while


.
:
{ do


}
) ( while

) ( do while :
- .
- ) ( do while
-
.
:
> <html
></title ><head><title
>"<script type = "text/javascript
; var i = 1
{ do
; ) document.write( i
; i ++
}
) while ( i <= 10
></script
></head
><body></body
></html

:
) ( i ) ( 1 ) ( do while
" ) " ( i ) ( ) ( i++ ) ( i
) ( i ) .( 2 ) ( do .
) ( i ) ( 2 ) ( 10 ) ( do
) ( i ) ( 3
) ( 3 ) ( 10 ) ( i ) ( 11
) ( do .
) ( while ) ( do while
. . .
) ( while
.
) ( do while
" ) . ( do
) ( do while
) ( while .
) ( :
; var i =5
) while ( i < 3
{
; ) document.write ( i
; i ++
}

; var i =5
do
{
; ) document.write ( i
; i++
) } while ( i < 3

) ( while ) ( 5
) ( 3 . ) ( i
) ( do while ) ( i
) ( i ) ( 6 ) ( 3
) ( do .
...

) ( while ....
do while ) .... ( 5

) ( while ) ( do while
) ( for
"
" ) ( for _ loop
) ( while ) ( do while
) ( do while
.

) ( break ) : ( continue

) : ( break
) ( while ) ( do while ) . ( switch


) ( break .
:
; break

:
>"<html dir="rtl
></title ><head><title
>"<script type = "text/javascript
; )"" "" """""" """"(var x = new Array
)for(var i=0 ; i <x.length ; i++
{
)if(i == 4
; break
; )">document.writeln(x[i] + "<br /
}
></script
></head
><body></body
></html

..
) ( x ) ( 7 . )
( for ) ( 0 ) ( i < x.lengh ) . ( 7

. ...

26

) ( if i == 4 ) ( break
) ( i ) ( 4 ) ( document.writeln
) ( break .
) _ _ _ (
.
) : ( continue
) ... ( skip
) ( 4 ...
) . ( continue
:
; continue

:
>"<html dir="rtl
></title ><head><title
>"<script type = "text/javascript
; )"" "" """""" """"(var x = new Array
)for(var i=0 ; i <x.length ; i++
{
)if(i == 4
;continue
; )">document.writeln(x[i] + "<br /
}
></script
></head
><body></body
></html

27

:
) ( x ) ( 7 . )
( for ) ( 0 ) ( i < x.lengh ) . ( 7

) ( .
) ( if i == 4 ) ( continue
) ( i ) ( 4 ) ( continue ...
... ) _
_ _ ( ) ( i ) ( 4
) ( ) ( continue ) ( skip
.
:
for
nested loop if

28

while for while

) : ( function

. .

) ( call function
" " .

. . .

. . .
:


. . .


.

. ) (

.

. . .
) : ( function

) ( function
{

; return
}

:
:
) ( Function
{
; return
}

) ( return
) ( return ) ( return
) . (
.
!
.
:
> <html
></title ><head><title
>"<script type = "text/javascript
; var z
; var x=2
; var y=3
; ) document.write ( x
; ) document.write ( " <br> " + y
; ) z = summation ( x , y
; ) document.write ( " <br> " + z
) function summation ( x , y
{
; var sum = 0
; sum= x + y
; return sum
}
></script
></head
><body></body
></html

. . .
) ( x ) ( 2
) ( y ) ( 3 ) ( z
) ( summation ) . ( x+y

) ( x ) ) ( document.write ( x ) ( 2
) . ( x
) ( y :
)document.write (" < br > " + y
:
; ) z = summation ( x , y

. . .
) ( z ) ( function
) ( summation ) ( x ) ( y
) .( z ) ( z .
) ( summation ) ( z
.. ) ( summation :
) ( sum " "
) ( sum
) ( 2 ) ( + ) ( 3 ) ( 5 ) ( 5
) ( sum ) .( 5
...
) ( sum ) ( x ) ( y "
) ( y ) ( x ) ( x
) ( y ) ( 2 ) " ( 3
.
) ( 3 ) + ( 2 ) ( 5 ) ( sum
) ( sum ) ( 5 .
) ( return ) ( sum ) ( return
. . ) ( sum ) ( 5
) ( :
; ) z = summation ( x , y

) ( summation ) ( 5 ) ( z :
; ) z = summation ( x , y

) ( sum ) ( 5
..
...
) summation ( x , y ) ( 5 ) . (.z


) ( z :
; ) document.write ( " < br > " + z

) ( 5 ) ( 5 ) = ( 3 ) + ( 2 ) ( return
" " ) . ( sum
) ( function ) ( return
.
) ( function ) ( return ) ( return
...
:
><html
></title > <head><title
>"<script type = "text/javascript
; var x = 4 , y = 2
; ) subtract ( x , y
; )" > </h3 >document.write (" <h3
) function subtract ( x , y
{
; var sub = 0
; sub = x - y
; ) document.writeln ( sub
}
></script
></head
><body></body
></html

:
) ( x ) ( y ) ( x ) ( 4
) ( y ) ( 2 ) ( function "
" ) ( x) ( y ) ( 4
) ( x ) ( y ) ( 2 ) ( function
) ( function ...
...

) ( sub
) ( x ) ( y ) ( sub
:
sub = x y

) ( sub :
; )document.write (sub

) ( 2 . . .
" "

" "
:
; ) " > </h3 >document.write ( " <h3

.
... ..
:
><html
></title > <head><title
>"<script type = "text/javascript
) ( function output
{
; var x = 3 , t
; ) t = cube ( x
; ) document.writeln ( t
}
) function cube ( y
{
; return y*y*y
}
></script
></head
><body onload = " output ( ) " ></body
></html

...
.
- "
" .
) ( function output

- ) ( y ) ( output :
; ) T = cube ( x

) function cube ( y

) ( x ) ( y
:
) ) ( function cube ( y ) ( x ) . ( 3
) ( x ) ( y ) ) ( function cube ( x
.
- ) ( 3 .
) ( return
" ... return ) ( function output
parameter ..
!
return
..
.
:
; return y*y*y

; var z
; z = y*y*y
; return z

.
- ...

) ( body :
> " ) ( < body onload = " output

) ( onload ) ( body
) ( onload
" " ) ) ( ( output
. ) ( onload ) ( form
.

) : ( Arrays

.
:
- ) ( 5
.
; ) var a = new Array ( 5

-
" ) ( for "
.
; ) ( var a = new Array

-
. .
; ] a = [ 3, 14, 6

- ) ( a
) ( 1,2,3 ) "" " " " " (
) ( 1,2,3
) ( . " ) ( string
) " ( .
; ) a = new Array ( 1, 2, 3
; ) " " " , " " , " ( a = new Array

:
. .

.
.
.
" " .
. .
) ( a :
; )" " ", " ", " ", "( a = new Array


.
.



.
" " Memory ...
" " :

50

]a[0

90

]a[1

20


Array

]a[2

45
]a[3


Index



Array

. . .

.
. . .
:
>"<html dir="rtl
></title ><head><title
>"<script type = "text/javascript
; )"" ", " ", " ", "( var name = new Array
; var i
) for (i = 0 ; i < name.length ; i ++
; )" >document.writeln ( name[i] + " <br /
></script
></head
><body></body
></html

. .

) ( name . ) ( i
. ) ( name.lengt

. 3 2 1 0
:
. length

. ) .. ( 4
. .
) ( 4 ) ( 4 ) ( 3 ) ( 3 , 2 , 1 , 0
. . %100
) ( 0 ) ( 4 ) ( 4 . ) . ( 4
) ..( name.length
) ] ( name[i
. . . .
. . . "[" . .
"]" ) ] ( name[0
. ) ( i
) ] ( name [i ) ] ( name [0
) ( i
) ( 1 ) ] ( name [1 ) ( 1 .
) ( i ) ( 2
) ( i ) ] ( name [2 .
) ( i ) ( 3 ) ] ( name [3
. ) ( i
) ( i < name.length ) ( 4 .
:

:
) . length (
. :
:
; )a = newArry (4

:
; )a = newArry (2,4,6

.
) ( a.length ....
:
; ) ( a = newArra

) ( .length
.
) ( a.length ) ( 3 .
:
><html
></title ><head><title
>"<script type = "text/javascript
; var i
; )(var number=new Array
)for (i=0 ; i<4 ; i++
{
; number[i] = i
;)">document.writeln(number[i] + "<br
}
></script
></head
><body></body
></html

.... ...

) ( i<4 " ) . " ( 0


) ( number[i] = i .
) ( 0 ) ( 1 . :
Number [0] = 0
Number [1] = 1
Number [2] = 2
Number [3] = 3

:
" . (1D) " One Dimension Array

:
" . (2D) " Tow Dimension Array

...
><html
></title ><head><title
>"<script type = "text/javascript
; ] ]var arr = [ [1,3,5,7] , [3,3,3,3] , [9,1,4,0
;)"></h2><tt >document.writeln("<h2
)for (i=0 ;i< arr.length;++i
{
)for (j=0 ;j< arr[i].length;++j
;)" " document.writeln(arr[i] [j] +
;)">document.writeln("<br /
}
;)" >document.writeln("</tt
></script
></head
><body></body
></html

...


.....


. ...
) ( ) (rows & columns
. ) ( 4 x 3



.. .
" " ) > ( <tt

.

" "



" " .

" "
.
"
" :

) : ( i " "
) : ( j "
" .

.....

) ( i ) ( 0
.
) ( arr.length ) ( 3 ) ( i < 3 ) ( 0 .
" " .
) ( var i ) ( i
.
" " .
) ( i ) ( 0 ) ( j
) ( 0 ) ( j ) . ( j<arr[i].length ) ( i ) ( 0
) ( arr[0].length
) ( 0
.. " ) ( 0
" ...
) ( arr[0].length ) ( 4
) ( j<4 ) ( 0 ) ( 3
" " .
. ...
) ( j ) ( 0 ) ( 4 . ) ]( arr[i][j

...
) ( i ) ( 0 ) ( j ) ( 0 ) ] ( arr[0][0 ) ( 0
) ( 0 ) ( i
) ( j .
...
.
"
".
) ] ( arr[0][0 ) ( 0 ) ( 0
) (0 ) ( 1
) ( j ) " ( 1 " ) ( 1
) ( arr[0].length ) ( 1 ) ( 0
) ] ( arr[0][1 ) ( 0 ) ( 1
) ( 3 ) ( j
) ( 2 ) ( 2 ) ( 4 ) ] ( arr[0][2 ) ( 0
) ( 3
) ( j ) ( 3 ) ] ( arr[0][3
..

) ( 0 ) ( 3 . ) . ( 5
) ( j ) ( 4 ) ( 4
) . ( 4 ) > ( <br / ...
) ( i ) " ( 1 ) ( 0
) . ( 1 " ) ( 1 ) ( arr.length
) ... ( 3 ) ( j ) ( 0
) ( j ) ( arr[i].length ) ( arr[1].length ) ( 1
) ( 4 ) ( 1
. ) ( 0 < 4 ) ] ( arr[1][0
) ( 1 ) ( 0 ) ( 7
) ( j ) " ( 1 "
) ] ( arr[1][1 ) ( 1
) ( 1 ) ( 9
) ( j ) ( 2 ) ] ( arr[1][2 ) ( 11
) ( j ) ( 3 ) ] ( arr[1][3
) ( 13 ) ( j ) ( 4 " "
) > ( <br /
) ( i ) ( 2
) ( j ) ( 0 ) ( j < Arr[2].length
) ] ( Arr[2][0 ) ( 15 ) ( i
) ( 2 ) ( j
) > ( <br / ) ( i ) " ( 3
" ) ( 3 ) ( 3
" "
. . .
) > ( </tt
. .
:
><html
></title ><head><title
>"<script type = "text/javascript
var arr = [ [2,4] ,
[6] ,
; ] ][8,10,12
)for (i=0 ; i< arr.length ; ++i
{
)for (j=0 ; j< arr[i].length ; ++j
;) " " document.writeln( arr[i] [j] +
;) ">document.writeln( "<br /
}
></script
></head
><body></body
></html

. . . .
:
) .length ; ++i <for (i=0 ; i

) for (var i in
----------------------------------------------------------------------------) [i]. length ; ++j <for ( var j=0 ; j

) ] [i for ( var j in

.
.
.

: Math Object
..
:
) ( Object ) ( dot ) .. ( 0
) ( Object ) ( Math " " mathematical calculation
" " :
) ( Math .

:
)Math.sqrt(9

) ( 9 ) ( 3

:
) ( M ) ( capital letter
) ( Math ) .... ( small letter

) abs(x )(x
) ceil(x
) cos(x )( )(x
) exp (x )(ex
) floor (x
) log (x )(x
) max (x,y ) (x )(y
) min (x,y ) (x )(y
) (x) pow(x,y ) (y )(xy
) round(x ) (x
) sin(x ) ( )(x
) sqrt(x )(x
) tan(x )(x

abs(7.2) = 7.2
abs(0.0) = 0.0
abs(-5.6) = 5.6
ceil(9.2) = 10.0
ceil(-9.8) = -9.0
cos(0.0) = 1.0
exp(1.0) = 2.71828
exp(2.0) = 7.38906
floor (9.2) = 9.0
floor (-9.8) = -10.0
log (2.718282) = 1.0
log (7.389056) = 2.0
max (2.3,9.7) = 9.7
max (-2.3,-9.7) = -2.3
min (2.3,9.7) = 2.3
min (-2.3,-9.7) = -9.7
pow(2.0,7.0) = 128.0
pow(9.0,0.5) = 3.0
round(9.7) = 10
round(9.25) = 9
sin(0.0) = 0.0
sqrt(900.0) = 30.0
sqrt(9.0) = 3.0
tan(0.0) = 0.0

:
><html
></title ><head><title
>"<script type = "text/javascript
;))document.write(Math.sqrt(9
;)">document.write("<br /
;))document.write(Math.max(10,2
;)">document.write("<br /
;))document.write(Math.sin(1.0
></script
></head
><body></body
></html

) ( Math Object ..
) ( 9 ) > ( <br /

"
" ...
:
:
)Math.max(Math.max(4,5), 6

) ( Math Object ) 4 ( 5
) ( Math Object ) ( 5
) ( Math Object ) ( 6 ) ( Math Object
..
-

:
...
))Math.max(Math.max(4,5),Math.max(11,20

Math.E
Math.LN2
Math.LN10
Math.LOG2E
Math.LOG10E
Math.PI
Math.SQRT1_2
Math.SQRT2

2.718

) (2 0.693
) (10 2.302
1.442
0.434
3.141592653589793
0.707
1.414
)(2.0

: Methods of the String Object

)charAt(index
)charCodeAt(index
)concat(string

)(index
)(index
) (string
) (concat ) (string
)(concat

fromCharCode(value1,value2
),
) indexOf(substring,index ) (substring
) (index
)(string .

) (substring )(string
) lastIndexOf(substring, index ) (substring
) (index

)(string .

) (substring )(string
) slice(start,end ) (start ) (end
) (string
) split(string ) (string
.
) (start
) (length) substr(start,length ) (string .
)substring(start,end
)(toLowerCase
)(toUpperCase
)(toString
)(valueOf
)anchor(name
)(blink
)(fixed
)link(url
)(strike
)(sub

) (start
)(end
) (string
.
) (string
.
)(string
)(string
)>(<a> name </a
) >(<blink></blink
)> (<tt></tt

)>(<a></a
)> (<strick></strick

)> (<sub></sub

)( sup )> (<sup> </sup

:
>"<html dir="rtl
></title ><head><title
>"<script type = "text/javascript
;"var a ="samialr
;) ) " + a.charAt(0 >document.write("<p
></script
></head
><body></body
></html

Date Object :
.
:
) (var a = new Date


)(getDate

)(getUTCDate
" 0 " " 6 "
)(getDay
" 0 " " 6 "
)(getUTCDay

)(getFullYear

)(getUTCFullYear
0 23
)(getHours
0 23
)(getUTSHours
0 999
)(getMilliseconds
0 999
)(getUTCMilliSecond
0 59
)(getMinutes
0 59
)(getUTCMinutes
" 0" " 11"
)(getMonth
" 0" " 11"
)(getUTCMonth
0 59
)(getSeconds
0 59
)(getUTCSeconds

..
)setDate(val
)setUTCDate(val
)setFullYear(y,m,d
)setUTCFullYear(y,m,d
)setHours(h,m,s,ms
)setUTCHours(h,m,s,ms

)setMilliSeconds(ms
)setUTCMilliSeconds(ms
)setMinutes(m,s,ms
)setUTCMinutes(m,s,ms
)setMonth(m,d
)setUTCMonth(m,d
)setSeconds(s,ms
)setUTCSeconds(s,ms
)setTime(ms
)(toLocaleString
)(toUTCString

:
) . ( string
:
; " var a = " thamer

) ( a ) " ( .
:
- ) " ( .
:
; " var a = " 123

.
:
; " var a = "ab12

) " ( .
- ) ( string .
:
; " @var a = "ab c12

)" @( ) ( Memory
.
.

:
) ( string
:
- ) .( string
; " var a = " Javascript

- ) ( Methods :
.
:
) ( . ) .( string
:
-
; " var a = "Javascript

- ) ( Methods of the string object


)a . substring(0,4

) ( a ) ( 4
) 0 1 2 ( 3 ... ) .( Java

:
-
; " var a = "Javascript

- ) ( Methods of the string object


)a . toUpperCase(0,4

) ( javascript
) ( JAVASCRIPT
) ( toUpperCase
.. .. :

) ( toUpperCase ) ( a


) ( 4 .
>"<html dir="rtl
></title ><head><title
>"<script type = "text/javascript
;" var a = " samialr
;" var b = " name
;))" + a.charAt (0 >document.writeln("<p
;) )( " + a.toUpperCase >document.writeln("<p
;) ) " + b.concat (a >document.writeln("<p
></script
></head
><body></body
></html

) ( Date object .
) ( Date

- ) ( Date :
;)(var d = new Date

- .
d.getDay() +1


Date

:
) ( 1+
) ( get ) )( ( getDate ) )(( getMonth
...
) ( set ) ) ( setDate(value ) ) ... ( setMonth(m,d

) ( getMonth
) ( get
.

) ) ( setMonth(2,1 ) ) ( setMonth(m,d
... ) ( m ) ( d
) ( 1 ) ( 1+
. ) ( get
) ( set
.
:
- :
0 1 2
.
-
) ( switch .

><html
></title ><head><title
>"<script type = "text/javascript
; )(var d = new Date
;))( <p>" + d.getDate >document.writeln("<p
;))( <p>" + d.getMonth >document.writeln("<p
;))( <p>" + d.getFullYear >document.writeln("<p
></script
></head
><body></body
></html

:
<html >
<head><title>< /title>
<script type = "text/javascript">
var c = new Date (2004 , 9 ,29 , 1 , 7, 0 );
document.writeln("<b>Date :</b> + " c + "<br>");
c.setDate(11);
c.setMonth(9);
c.setHours(23);
c.setFullYear(2003);
c.setMinutes(50);
c.setSeconds(55);
document.writeln("<b>Dtae : </b>" + c);
</script>
</head>
<body></body>
</html>

:
) ( c ) ( Date Array
.
;) newDate (2004 , 9 , 29 , 1 , 7, 0

2004 9
29 1 7
. 0 : , , , , , .
:
;)document.writeln("<b>Date : </b>" + C

) ( c
) .( c
) ( c . :

;)c.setDate(11
;)c.setMonth(9
;)c.setHours(23
;)c.setFullYear(2003
;)c.setMinuites(50
;)c.setSeconds(55

) ( c
) ( set
) ( Date ) ( FullYear .
) ( c .
;)document.writeln("<b>Dtae : </b>" + c

.

.
) ( get
) ( set .

<html dir="rtl">
<head><title>< /title>
<script type = "text/javascript">
var d = new Date() ;
switch( d.getDay()+1 )
{
case 1 :
document.writeln(";)"
break ;
case 2 :
document.writeln(";)"
break ;
case 3 :
document.writeln(";)"
break ;
case 4 :
document.writeln(";)"
break ;
case 5 :
document.writeln(";)"
break ;
case 6 :
document.writeln(";)"
break ;
case 7 :
document.writeln(";)"
break ;
}
</script>
</head>
<body></body>
</html>

) ( switch
.
) ( Date :;)(var d = new Date

) ( switch ) ) ( switch( d.getDay()+1 ) ( switch



) ( switch
;)(var d = new Date
;)(var n = d.gateDay
) switch ( n
{

) . ( switch

:
( forms )
( status )

..
:

<html dir="rtl">
<head><title> java script </title>
<script type="text/javascript">
function information()
{
var name=info.name.value;
var job=info.job.value;
var add=info.address.value;
var comm=info.command.value;
document.writeln("<table cellspasing=\"0\"
cellpadding=\"5\" border=\"1\" width=\"80%\"
align=\"center\" dir=\"rtl\" bgcolor=\"#eaeaea\"
bordercolor=\"#000000\">");
document.writeln("<caption><h3>
< /h3></caption>");
document.writeln("<tbody>");
document.writeln("<tr><td width=\"30\"><b> :
</b></td><td>" + name + "</td></tr>");
document.writeln("<tr><td width=\"30\"><b>
:</b></td><td> " + job + "</td></tr>");
document.writeln("<tr><td width=\"30\">
<b> :</b></td><td> " + add + "</td></tr>");
document.writeln("<tr><td width=\"30\">
<b> :</b></td><td> " + comm + "</td></tr>");
document.writeln("</tbody>");
document.writeln("</table>");
}
</script>
</head>
<body >
<form name="info" action="">
<table cellspacing="0" cellpadding="5" border="0" width="80%" align="center">
<tbody>
<tr>
<td> : </td>
<td><input type="text" name="name" value="" size="31"></td>
</tr>
<tr>
<td> :</td>
<td> <input type="text" name="address" value="" size="45"></td>
</tr>
<tr>
<td> :</td>
<td><input type="text" name="job" value="" size="20"></td>
</tr>
<tr>
<td> :</td>
<td><textarea name="command" rows="4" cols="50"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
</br>
<input type="button" name="show" value=""
onclick="information()"><input type="reset" name="del" value="> "
</td>
</tr>
</tbody> </table></body></html>

58



..
:
:
; var name=info.name.value
; var job=info.job.value
; var add=info.address.value

..

59

) ( name ) ( job ) ( add


... ) ( a
:
; ) (var a = new Array

..
) ( name )
( form ) ( a .. ) ( name
:
; var name=info.name.value

) ( name
) ( form ) ( name ..
... :
; info.name.value

) ( info ) ( form
> " "=< form name="info" action

) ( html
.. ) ( name ..
) ( name
) ( name :
> < input type="text" name="name" value="" size="3

) ( input
) ( name .

) ( value ..

60

:
; var name=info.name.value

..
) ( name ) ( job ) ( add
..
:
. ) ( a . :
; var a=myform.enter1.value

) ( form
..
:
; var a=myform.enter1.value

) ( form "
" myform :

> " "=< form name="myform" action

" " enter1


:
> "< input type="text" name="enter1" value="" size="31

:

..
:

>")(" onclick="information"=<input type="button" name="show" value

) ( button :
")(onclick="information

61

) ( button
function
) ( onclick ) ( button )
( function ) ( information ..
..

..
) ( document.writeln
) ( html ) ( html
.. ) ( body ) ..( html

..

:

) ( button
) ( body ) ( form
..
:
)
@ (

function if function
function .

) ( status window
:

status

62

) ( status
:
; " " = window.status

) ( status :
; window.status = name

) ( status :
-
; " " window.status = name

.
-

; " name " = window.status

:
> <html
></title ><head><title
>"<script type = "text/javascript
; " " = window.status
></script
></head
><body></body
></html

63

.
status ...
.. Array for .

window

..

> <html
></title ><head><title
>"<script type = "text/javascript
window.open ("www.freewebs.com", "new_web", " toolbar = no ,
location = no , directories = no , status = no , menubar= no , scrollbars
; ) " = no , resizable = no , copyhistory = yes , width = 400 , height = 400
></script
></head
><body></body
></html


window
toolbar
...
yes no ..

> <html
></title ><head><title
>"<script type = "text/javascript
) (location.reload
></script
></head
><body></body
></html

reload ) ( location.reload refresh


.
:
break ) ( location.reload
refresh
> <html
></title ><head><title
>"<script type = "text/javascript
) (window.print
></script
></head
><body></body
></html

64

) ( window.print
.. file print
..
button ..
function HTML
onclick function form
.

>"<html dir="rtl
></title ><head><title
>"<script type = "text/javascript
; )">: "+ navigator.appName + "<br / "(document.write
; ) ">document.write (window.screen.availWidth + "<br /
; )">document.write( window.screen.availHeight + "<br /
; )">document.write( window.screen.colorDepth + "<br /
></script
></head
><body></body
></html



..

navigator.appName
.
window.screen.availWidth
. RESOLUTION SCREEN
window.screen.availHeight
. RESOLUTION SCREEN
window.screen.colorDepth
settings
color quality 32 bit ... 16 bit

65

You might also like