Javascript Bangla
Javascript Bangla
skp Syntax
skp Enable
skp Location
skp External
skp Operator
skp Variable
skp Function
skp Event
skp Statement
If Statement
Else If Statement
While Loop
For Loop
Comments
skp Array
skp Alert
skp Confirm
skp Prompt
skp Print
skp Redirect
skp Popup
skp Date
skp
skp s
skp p
skp indexOf
skp getElementById
skp inner
skp u
| ( Javascr i pt Tut or i al i n Bangl a)
:
e! e !"# ! $ " p &' &ei $ " ! stpskp +
e kin i. skp
$# & bu skp
kin i. skp
$# e a1 + c 3 o 5& bu & " bu ei skp$#
run/execute &kin i. e
&67" +
i., i.
$# $#
. o & e 8 execute/run +5stp e p8! #&8
+
e 8
i
e p" 9! :; e 35
stp e + 3 ! $#
e 35
Alert
666 ui n
HTML Form
.'!
si. '
n &
webcoachbd.com e u
5
$#
6@
6! &
5 skp (Javascript) ' " 6 &!
p5 6A&:n ei u
'## $ 6! a&'i eiee
m n
! " + &
skp
$
%
& ' ( Javascr i pt Synt ax Tut or i al i n Bangl a)
:
F
01.<html>
02.<body>
03.<script type="text/JavaScript">
04.<!-05.document.write("Hello World!")
06.//-->
07.</script>
08.</body>
09.</html>
p'!:
Hello world!
document.write:
script e '9 86 + c '! e &&+ 3 ! document.write 8 text, HTML a1& Ji
3 ei '! e e
&" text string &&+ F 3 "Hello World!" ! 6" e bu e
p'" + &
SYNTAX $ 6h:
6h:
u6 stp .
k
" 6 &! 3 "document.write(Hello World!)" ei statement e ' 9 !
! !i ! p " statement e '9 ! ' " stp e
! e p ! !i
" & 6! 3 aj pg + 1 ! " & k t &&+ " 6 ! " &
! &&+ #7 3! e
i ! # statement ( # document.write statements )
stp F
01.<html>
02.<head>
03.<script type="text/JavaScript">
04.<!-05.function popup() {
06.alert("Hello World")
07.}
08.//-->
09.</script>
10.</head>
11.<body>
12.<input type="button" onclick="popup()" value="popup">
13.</body>
14.</html>
p'!:
e
'! "7 F 3 ! 666 e& e
eiee
.k n e head
$ e F e! 3"&i
&
! k & ""&i "Hello World!" ! alert box & 6&" a8$#
" '! e& event m n &s"
! + F
$':
$':s $ ek-R
skp Ei
( Ext er nal JavaScr i pt Fi l e Tut or i al i n
Bangl a)
:
alert function 8!
p'!:
F# Tips:
1 6! 3 ei Script &n 6 &&+ " ! "+
external skp file &&+ " 6 !e
ei .
p " 6 !
p ! !i
2 u 8 ! Script e ! external skp file &&+ 3 3! e!
i6 3 head tag (functions) e
+
i6 3 body tag e +
3 6! !Y" " + & 3 external skp file e <script> tag an#k + & ! ! '#8# t HTML
comment e& skp code Fa F# 1 & !
skp a,
u
( JavaScr i pt Oper at or Tut or i al i n
Bangl a)
:
1
u+!
3$
2+44
& $
6-22
$#!
7*44
$
15/3
15 3
.#
43%
43 10
skp a,
e 0
$
9' uP'-:
uP'-:
! e
8! u+! +
3 !
6$!"7 3 mn + F
01.<body>
02.<script type="text/JavaScript">
03.<!-04.var two = 2
05.var ten = 10
06.var linebreak = "<br />"
07.
08.document.write("two plus ten = ")
09.var result = two + ten
10.document.write(result)
11.document.write(linebreak)
12.
13.
14.document.write("ten * ten = ")
15.result = ten * ten
16.document.write(result)
17.document.write(linebreak)
18.
19.document.write("ten / two = ")
20.result = ten / two
21.document.write(result)
22.//-->
23.</script>
24.</body>
p'!:
two
ten
ten / two = 5
plus
*
ten
ten
=
=
12
100
Operator
1
u+!
==
Equal To
x==y
1
!=
Not Equal To
x!=y
"
<
Less Than
x<y
"
>
Greater Than
x>y
1
<=
x<=y
"
>=
x>=y
1
skp 0
$
u
( JavaScr i pt Var i abl e Tut or i al i n
Bangl a)
:
&
+
e
p"7 (symbolic) ! 3 6! ! ;
# u6s6! &
e
e u d' + c 6!
"1 3 " 6! 6&" " " &&+ " 6 ! &
!
! 3 e
& & $ 1 "#
!
"+
ei & $ & .
(data) 1
1 "#
! 3 Variable ! ( name) d .
a ! 1 3 " 6!
+ e
move "
" 6 !
6 !
&
e u+!:
u+!
p1& &
&&+ k t &
! 6# & "var"
#7 ! " &
programming practice e !
p1& &
! 6# & "var"
u"! u+ ! 8 &9 6s +
01.<body>
02.<script type="text/JavaScript">
03.<!-04.var linebreak = "<br />"
05.var my_var = "Hello World!"
06.
07.document.write(my_var)
08.document.write(linebreak)
09.
10.my_var = "I am learning JavaScript!"
11.document.write(my_var)
12.document.write(linebreak)
13.
14.my_var = "Script is Finishing up..."
15.document.write(my_var)
16.//-->
17.</script>
18.</body>
p'!:
Hello
World!
I
am
learning
JavaScript!
Script is Finishing up...
u6 u+ ! # &
"7 F 3 e
i! b ! HTML 8 F a6 + c .i! &
3 u6 script e 8 "! n 8 !
# F
&
e
# ! ; " ! h (=) &&+ " + & 3 ! & 6 ' 1 & &
e& .! 6 ' 1 & &
e
# 3! my_var = "Hello World!" e ! + c my_var ! "Hello World!" &
e& e
#
& ! order h " + & a1Z p1 &
e ! 6 &
e
# " ! +
script h" & !
skp 0
$
-
--W&:
--W&:
3! 6! &
! ( name)6Fn
6Fn &! "! a&'i
k " + & ! 3! skp ereserve
! !
e
+ &
! (name)6F n
6F n
practice +
&d!i
! &&+ 3! ! &
# e 1 ! '
3! 8#! 6! &
# #" i ! ' F k t &
! " 6 ! "shoe_size" 3 #&
+ 6a e& &I 3 &
skp &
! (0
0-99) '## + & ! 3 &&+ &8 ! 3!:
3! 7lucky, 99bottle e& 3charm
&
+ &
! F
+ " &d '## e& &
!
! 3 e a8 'b &'s + "+
'b$#
underscore 6:1 " + 3!:
+ 3! my_var, strong_man, happy_coder i"
3 6! ! pg e aj" 1 "+
ei a8 ' "
$ & a!! pg
$# (,
++,6ei6 i") '! e " skp e '! pi ei e 3 6! '! ' p1& + 1 "+
ei
a8 #& ! 3$ + 6a u"
E[\- ?
?
'! +
e
# . 3 #p a&s 1 3"kd 63n ! " " &
+ 6#!&:t k t '! a !
&n '! e 8 ei . & & !
ei & & 3
skp '! e u+!:
u+!
'! eiee
.k n e head
$ e " u" '! "7 #& + p1 '! e ! " + &
"6 8! skp .
" + & u+ ! 8 &9 6s +
01.<html>
02.<head>
03.<script type="text/javascript">
04.<
05.function popup() {
06.alert("Hello World")
07.}
08.>
09.</script>
10.</head>
11.<body>
12.<input type="button" onclick="popup()" value="popup">
13.</body>
14.</html>
p'!:
'! 1
8 browser &#I F 3 '! &&+ " 3c "6 '! e ! F 3 "
e
6&" " &&+ " 6 3 +"# pop up alert "7 F
ei '! "popup" '! &
. "
6 ei "{,}" b
'! . e 7! !8!
popup '! e . ei b
"
+
8!" e
&9 e
$ " 6 3 & popup '! e " alert '! &&+
ei
alert '!
popup box + p'! e
i +
'! &&+ & &a &9 " +
'! e "
'! e &&+ u+ ! F &
! click
popup box F &
! click event &
e &9 6&" a8
! + F
skp i
? u
( JavaScr i pt Event Tut or i al i n Bangl a)
:
skp &9 6 '7"
&6 + c e k" d 6! .i! o & 6 " +3 &
6! i
e !
p!&n , ! & 7&n ! + & 9!7 o & 6 "7 t + c skp i n skp e
i n +
e! e ! 3 o & 6 e 1 & e u6 F#
skp i n e F# u+! +
1 e u k
2 o & 6
. +o
3 h" s ! u6 u 3 hover ! !
4 eiee
e i!6#
&k
k
5 e keystroke
skp i ns e u+!:
u+!
skp e F# 6#& !8" ! F 3 8 a ! i n
u6 "
s + F 6! 3! i n ! ;
&! "! F# " + 6! a&'i i n ! ; " + & ! HTML element i n e ! a 6k
& e& i n
1 1 function &
6#&& " a8 skp i n &&+ F
3 ! &
! k 1 1 alert popup p'! F
F
"onclick" skp i n ei
+
view source
print?
01.<html>
02.<head>
03.<script type="text/javascript">
04.<!-05.function popup() {
06.alert("Hello World")
07.}
08.//-->
09.</script>
10.</head>
11.<body>
12.
13.<input type="button" value="Click Me!" onclick="popup()">
14.
15.</body>
16.</html>
p'!:
skp 0s
? 0s
? u
( JavaScr i pt St at ement Tut or i al
i n Bangl a)
:
6! ic" skp .
" 6 ! " & &' $ k t skp .$#
6:1 6:1 s
n & &&:" d $h"
e s
n &
" 6 3
# ! e s
n '!
" 6 s
n ! ' 3 Script
& e& & &
0s
? e 9p:
9p:
a!! pg
$# (,6ei6 i") e p ! ' " semicolon(;) &&+ + skp e F
3 semicolon(;) e &&+ &8&8" &9 !
0s
? e p
P:
p
P:
!m" s
n 3 &
e ! 6&" !, !"# ! ! p! & '! . i" m& F#
p s
n F 3 " u d' a!#37 e a6 + " 6:1
ei a8 e& p s
n e kp 8! & " & 6&" a8 e &9
! + & ! e p
u l +
1 n'!
('"
'" &)
& s
n
2
#6 (6#6#!&:t)
t s
n
3 a& k (&si
&si ) !6#
'! s
n
4 n (n&
n&)
n& s
n
5 ek 6'! (&"k
&"k)
&"k +n
s
n
n'!
s
n:
3 6! 100
! .
"! , " & 6! m&" F a &! ' 9 '" &(
conditional) if/then
statement 3 pg e k t a8 6 ! &&+ +
+
F#(6! F a )
& 3
'" (condition)(a1
a1Z 6!
" " 6 !!)1
6 !! 1 +," &
+ " & 6! i (
F a ) "
" 6 &! !
!
6! Script !nt! ! n'!
s
n &&+ + 3 " a&s 6 pk " &n 3 8#!
6! ! & '9 F& F# ! 6! website e home page e " ! ei '" ! ! F
e& 3 e
F# ! + " & F# ! ! & '9 F& 6! website-e
! p'" + &
n'!
s
n m n h j! Fa 6! 6! website p"' a!#37 p!&n,9!7,.! " 6 &!
!
a, (,a-$bt)
t) 0s
?
6! !o & !nt!6t 6h F
!? 3 ! 6A! " & !#! e
e & 6A " + p1 !nt!6t ! &! "6
t# &!, # 1#1# &!, #
& e
&! "6 6h &! 3 6! 100 !nt!6t 1 " &
& 99 ei & " + & e & && ei &k
" & ! + 6d" F? +n ,pg e k t + u6 F " skp 3 ei 6d" ! + c
"looping" 6l! 8 looping e + 3 6! 6! F
#n Script 'k'
7 k a w 6!"
" 6 &!
loop statement "n 3, ! '" " + c !3 ! '" " + " & loop statement '" 6 k
skp . 6!" skp . 6!" 6 '" " & + 3 '" h 1
" & pk & '## + 3 '" 1 + " & loop (a1Z 6#!&:t ) 1 3 &3 && + !nt!6 t 1
n " & p1 & ! !nt6t & F ! & 1 "+
e
$ " 6# 6A &
3 & ! 1 " & looping &n + 3 &
a$
k ($s) f-,a
\- 0s
?
0s
?
object model e # 3$ #&8 6 " ei statement $#
&&h" + e #+# " 6! 3 object model m n ! &# I!
" & !i e &9 6
! + F
? (n$f)
n$f) 0s
?
Comment statement d 6! 3 .
$ " ! ! i . bu 3 mn +o 1 &" "
6 ! " & ! px $ " 6 ! " " i? " a ! ! F 3&
p ' a!#" i!
& '#8# ! ! F 3 HTML comments e " & p ! " & . 3
$ "
6
Single
i! comment e #
//(slash) 1 a8
i! &'; '## + (/*) e& '9 + (*/) 6&" "
e &9 &s"
! + F
skp iE 0s
? u
( JavaScr i pt I f St at ement Tut or i al i n
Bangl a)
o!#
p'!:
Lucky 7!
u6
u+ !
variable
!
F myNum e& "
#
F " + c 7 Num e ! &
"!m &I"6 & 3 If
Statement' e '" 6#!# + c ! a1Z myNum ! 7 + c ! ("myNum == 7") 3 + " & e
" &
& &! &
( Lucky 7! )p'" + &
! n'!
s
n " F
3 . If Statement ("document.write...") e 1 |; F
"
3 6!" + F
skp I F STATEMENT: ELSE
e
! + F 3 3 '" " + " & & . 3 6!" + 3 '" 1 + " & 6! 6!
ic a!#37 . 3 6!" " 6 !e
+ c If Statement e &8" a'(extension) " + c
Else clause
Else clause 3! n'!
s
n 1 + u6 u+ ! 1 '#8# Elseclause 3$ F
e& myNum e
# (7 e 6& " 10)6&" ! F 3 " n'!
s
n 1 +
01.<script>
02.<!-03.var myNum = 10;
04.
05.
06.if(myNum == 7){
07.document.write("Lucky 7!");
08.}else{
09.document.write("You're not very lucky today...");
10.}
11.//-->
12.</script>
p'!:
You're not very lucky today...
skp e
9 iE u
( JavaScr i pt El se I f St at ement Tut or i al
i n Bangl a)
:
6#&&" a8 6! ' F! 3, skp- e & basic If Statement "7 3 single If Statement e
e a8 '" !d k t basic If Statement +" 1
Else If statement +
basic If Statement e e extension 3 8 6! a !$#
conditional
statement "7 " 6 !
skp ELSE I F e uP'-:
uP'-:
8#! 6! c! 6! F
"student" script customized p'" + 3 ! o & 6
&&+ F 3 6! e a8 custom 1 " & extension + & 6! Else If statement
&&+ " 6 !
01.<script>
02.<!-03.var visitor = "principal";
04.
05.
06.if (visitor == "teacher"){
07.document.write ("My dog ate my homework...");
08.} else if (visitor == "principal") {
09.document.write ("What stink bombs?");
10.} else {
11.document.write ("How do you do?");
12.}
13.//-->
14.</script>
p'!:
What stink bombs?
ia grt,a-R $m:
$m:
1 Else If statement &&+ $ 6! a&'i 8! If Statement &&+ " + & !Else
If statement + c basic If Statement e &8" a'
2 6! a ! $#
Else If statement 1 " 6 , u6 u+ ! t Else If statement e &&+ F
" & 6! 6! ic " Else If statement &&+ " 6 !
while loop +
e advance pg 6d" 3 8 ! && " 6 ! 3! 6! n'!
s
n
" + & 3o while loop e 8! &&+ e
#
e a8 6! & & skp e while
loop "7 3
skp WHI LE LOOP e $f%f:
$f%f:
skp while loop e p8! # a' F
1 while loop e . 3 6!" +o ! a&'i n'!
s
n " + " + &
2 while loop e . & ! b
"{ }" 8! 3 6!" + & 3 n'!
s
n " +
3! while loop '## +, skp 3 condition statement " + F ! " + " & & !
b
"{ }" e 8 . 3 6!" + & a ' ' 9
p'!:
While
myCounter
myCounter
myCounter
myCounter
myCounter
myCounter
myCounter
myCounter
myCounter
myCounter
While loop is finished!
loop
is
=
=
=
=
=
=
=
=
=
=
beginning
0
1
2
3
4
5
6
7
8
9
1 3 10 + " F
while loop e . 3 6!" + & pk
" 1 &
myCounter 3! 10 3 10 + " F
! k t while loop e . 3 6!" + & ! "i
# 10 p'" + !
'9
# + & 9 p'" + F
skp E
a, u
( JavaScr i pt For Loop Tut or i al i n Bangl a)
:
ad# "
!
+ "
6
" &
1-3
&i
ei
i !
.
!
!
+ c
#6 standardpg e a!#'7
! designer $d a!#& " 6
#6 e 8 F# s e& &':
+ " k
6o 3
skp E
a, e uP'-:
uP'-:
ei u+ ! 8 & 3 & 8!
#6 "7 3 e& counter e value p'" + & 3"k!
! counter 5 e 6F loop . p1
i ! "! n (i = 0; i < 5; i++)item e & '9 ! 3$
u" e$#
#6 e $#t# 6#! &9 3 u6 1 + " 3 6 n
! + F
01.<script type="text/javascript">
02.<!-03.var linebreak = "<br />";
04.document.write("For loop code is beginning");
05.document.write(linebreak);
06.
07.for(i = 0; i < 5; i++){
08.document.write("Counter i = " + i);
09.document.write(linebreak);
10.}
11.
12.document.write("For loop code is finished!");
13.</script>
p'!:
For
loop
code
Counter
i
Counter
i
Counter
i
Counter
i
Counter
i
For loop code is finished!
counter variable ! (name) i ad# "
$ " 6 " & e
&&+
is
=
=
=
=
=
beginning
0
1
2
3
4
loop counter e default (name) ! a!! ! variable ! + c j,k,x,ye& z
ei u+ ! counter p1 0 " ("i = 0;")
+ F "6 conditional statement
("i < 5;")
+ F counter 5 + " F
"i
#6 e . (executed) 6!" + F
#6 e . (executed) 6!" +o 6 ("i++") &:d
F counter i ! 1 + & "7 + F
+ 3 5 e F
+ " & 6#!
#6 e . (executed) 6!" +ei looping
"
1 3"k! ! counter i 5 e ! + c ni 5 " 5 + " F
!
#6 e . (executed) 6!" +o
&n + 3 &
6! !o Script & pg a"7 "
F! 3 F $ F! ni ! 8! !i 3 ei . 6!
&!6! m&" #
$ F! " F
! ! n (Comments)
u"
3! 6! .
! "! 6! a !
1 " 6 " & &
+ . 1 F# n
(Comments)an k 3 6! & & + " 3 c e
'#8# 6! 6&" " s! " +3 & " !,
6! 3 6! . u ! " & "o #& + . &#I " 6 & n(Comments) e &a #&8 + c
3! 6! . #
t # n(Comments)e + 3 a!" . # " 6 &!
ei a8 6! & & #i 8 ! n(Comments) JavaScript e
3
1 single
i! n( comments )
2 multi-
i! n( comments )
p'!:
I have comments in my JavaScript code!
MULTI - LI NE COMMENTS p&W :
:
3o single
i! n (comments )
# u67 " & 3! 6! ! &a a ' . ak " ! k t
single
i! n( comments ) e &&+ !o !o &I + a e &a 8 ! n( comments )
e ! skp multi-
i! n( comments ) &&+ u"3 '## + /* e& '9 +*/
01.<script type="text/javascript">
02.<!-03.document.write("I have multi-line comments!");
04./*document.write("You can't see this!");
05.document.write("You can't see this!");
06.document.write("You can't see this!");
07.document.write("You can't see this!");
08.document.write("You can't see this!");
09.document.write("You can't see this!");
10.document.write("You can't see this!");*/
11.//-->
12.</script>
p'!:
I have multi-line comments!
skp af
u
( JavaScr i pt Ar r ay Tut or i al i n Bangl a)
:
a +
e &
3 ! 8 a !$#
&
" 6 a ! pg a!
$# a F 3
skp + " n !
3! 6! skp e a &&+ &! "! ! 6 n$#
a&'i ! u"
1 a + c e
& '9 8 ! &
2 array name &&+ 8 a e
# + a " a&s! h 6! ic a!#37
b
# " 6 ! 3!: myArray[2] = "Hello World";
3 array name e 8
# e& " a&s! & 3 : myArray[2]
4 skp e a e ! built-in function F "i &&+ $ ! u"
skp af
p&W -:
-:
8! &
"7 + " a "7 F#
n ! JavaScript e &
e& property F 3 a e
+" |; !"# ! a "7 " 6! special function &&+ " 6 ! ! u+ ! 8 ! + F 3
& 6! 8! a "7 " 6 &!, !
# " 6 &!, i
# !d " 6 &!
01.<script type="text/javascript">
02.<!-03.var myArray = new Array();
04.
05.myArray[0] = "Football";
06.myArray[1] = "Baseball";
07.myArray[2] = "Cricket";
08.
09.document.write(myArray[0] + myArray[1] + myArray[2]);
10.//-->
11.</script>
p'!:
FootballBaseballCricket
k 6! b
# position h
6! ic a!#37
# & " 6 F!
skp af
9R[:
8#! 6! a &d
a!# " (sort) ! " a e sort method e 8 " 6
01.<script>
02.<!-03.var myArray2= new Array();
04.
05.
06.myArray2[0] = "Football";
07.myArray2[1] = "Baseball";
08.myArray2[2] = "Cricket";
09.
10.
11.myArray2.sort();
12.
13.
14.document.write(myArray2[0] + myArray2[1] + myArray2[2]);
15.//-->
16.</script>
p'!:
BaseballCricketFootball
3 6! o & bu e skp ek ! 1 "+
6! Alert " 6 &! ! skp e
+ c e
.
$ &k 3 pops up e&
" bu ui n + " :; 9! o & bu Alert 6a " &8
r%- + POPUPS / ALERTS $f$' $:
$:
! a&s k t JavaScript alert &&+ 3
1 6! 3 !Y" + " ! 3 &&+7(user) website e ! F# $ !
2 F# &9 m n &&+7 (user)" " 3!:ei " " 6 !
"the following page contains humor not suitable for those under the age of 14"
3 e
#
+ $ F e &6 6! &&+7 (user) ! " !
4 F# &6 !Y" + " &&+7 (user) j " 6 ! 3!: 3 " &a # k &6 i! "
+ " & 6! " & j &! 3 " # k &6 !Y" " & " ei d n o" 6a &
9n- skp e
R:
8#! e "7 F 3 ! !$! &
+ F &a ! p! # k &6 !$ ! 1 # k &6 !Y"
! e alert 3 o &i
e 3$ " + & ! . alert 3#k + F 3 ! eiee
e&
&
! onClick event 3#k + F
1.<form>
2.<input onclick=
3."alert('Are you sure you want to give us the deed to your house?')"
4.value="Confirmation Alert">
5.</form>
p'!:
String a1Z alert e b
" 3
" alert box e " pn + F &
! k 1 1
! p'" + &
p'!:
.
a '
k #! ! e + ("Leave webcoachbd.com?")
'! . F
JavaScript
skp pm
e &&+ &" ! 3 skp pm
e u d' + c &&+7(user) + " "1 g+ 3 " ei
"1$#
e &&+ 3 3
&&+7(user) &k$" a!##" :; + &
$ ! prompt e &&+ $ F ! personal webpage e ! j + " "6 "1
6
6! a&! + " 3!: "Welcome to My Personal WebPage ferdous alam!" (e ! 6! 3
! &! " p'" + &)
skp pm
#&
$ ! e
a ! F &k " & ' ! e ! ' &
9n- JAVASCRI PT PROMPT:
01.<head>
02.<script type="text/javascript">
03.<!-04.function prompter() {
05.var reply = prompt("Hey there, good looking stranger! What's your
name?", "")
06.alert ( "Nice to see you around these parts " + reply + "!")
07.}
08.//-->
09.</script>
10.</head>
11.<body>
12.<input type="button" onclick="prompter()" value="Say my name!">
13.</body>
p'!:
JavaScript print '! ei 3! 6! bu ui n i
!# print a6'! JavaScript
print '! o & 6 e !
n &&+7(user)pn 6h
a ! ei '! a!1 ! a ! F 3 mu
m n
3 ! ! " k t ei a6'! 1
a ! #&8
+ &
JAVASCRI PT PRI NT SCRI
SCRI PT - WI NDOW. PRI NT( ) :
JavaScript print function 3 window.print() e o & 6 pn ei '! eiee
&
! &
3 onClick event e 8 &
view source
print?
1.<form>
2.<input type="button" value="Print This Page" onClick="window.print()" />
3.</form>
p'!:
skp ,-:-
PR\ $ 1i
k u
( Javascr i pt Redi r ect Tut or i al
i n Bangl a)
:
! 6
. + & JavaScript property window.location e + 3 !nt! 3 window.location "6
"=" he& "6 !"# ! URL
6! &" ! 6 1 ! ; 6 3 " 6 ! 6! 3 !
&&+7
6! i
t 1 1 redirect + www.google.com e
" & ! .
#!
1.<script type="text/javascript">
2.<!-3.window.location = "http://www.google.com/"
4.//-->
5.</script>
JAVASCRI PT TI ME DELAY
DELAY
e
! mk 6s" " &' u67
1.3 ! 6
'! 6&" ! ! "+
"Update your bookmarks " e 8 ! e
!"# !
' !
! 3 " 6 !
2.! ; 6 6 3 6! 6! o &i
' " !
! u+ !
" k
tizag.com e e
6 ! 3 &a1Z !"# ! 6
'! tizag.com e 6
01.<html>
02.<head>
03.<script type="text/javascript">
04.<!-05.function delayer(){
06.window.location = "../javascriptredirect.php"
07.}
08.//-->
09.</script>
10.</head>
11.<body onLoad="setTimeout('delayer()', 5000)">
12.<h2>Prepare to be redirected!</h2>
13.<p>This page is a time delay redirect, please update your bookmarks to
our new
14.location!</p>
15.
16.</body>
17.</html>
p'!:
Time Delay Redirect
Time Delay a1Z F# e
6 " JavaScript e setTimeout function a&'i &&+ &
3 function delayer() 5 n (5000
n) " " i k t setTimeout
& 3
# &9 F
1. 'delayer()' i setTimeout()function ! ; 6 3! 6!" +
2. 5000 -
n
i
function delayer()
6!"
+
$
skp ,, +, ui
?1 u
( Javascr i pt Popup Wi ndow Tut or i al
i n Bangl a)
:
p'!:
CLICK ME TOO!
JavaScript Window.Open Arguments:
window.open() function 8 popup window customize " 6 window.open
function e "! 8 ! 3#k F
Dependent, fullscreen, resizable,e& status &$# ON/OFF properties e u+! 6! " 'i!
14.</form>
15.<p onClick="myPopup2()">CLICK ME TOO!</p>
16.</body>
p'!:
CLICK ME TOO!
Date object #&i $#t# 6#! 3! 6! " p'! " ! a1& e p calculation e k t timestamp &&+
skp e &&+7 computer clock a!#37 Date object "7 +
3! Date object "7 + mu
e an7! a!#37 "! e
#&i $#t# 6#! 3 u &n & u
3 n time zone e a&s!
skp &% (+
$&R- 9)
9) :
skp Date object e k" &a " + F# u" 6! 3 Date constructor (3 Date object
"7 ) ! 3#k & '" ! ! " & e &&+7 computer clock a!#37 Date object "7 &
1.<h4>It is now
2.<script type="text/javascript">
3.<!-4.var currentTime = new Date()
5.//-->
6.</script>
7.</h4>
p'!:
I t i s now
p'!:
I t i s now
01.<h4>It is now
02.<script type="text/javascript">
03.<!-04.var currentTime = new Date()
05.var hours = currentTime.getHours()
06.var minutes = currentTime.getMinutes()
07.if (minutes < 10){
08.minutes = "0" + minutes
09.}
10.document.write(hours + ":" + minutes + " ")
11.if(hours > 11){
12.document.write("PM")
13.} else {
14.document.write("AM")
15.}
16.//-->
17.</script>
18.</h4>
p'!:
I t i s now
3 hours or minutes variable 10 + " + " & 7 8 9 i" " & ei ! 'i! & !
a1Z 07, 08,
09 i" 3 + 1:01 am " & 1:1 am
!
&
"+
e &a I
F# !i skp e 8 e& I
ea " 6 ! ei '
&
+ "
.'!"
skp
.'! e! e '
3 8 &&+7$! .
&
$ " e "1 3i
skp 6! +37 e
& e&
&&+7$! ! & 3 " "1 #
& am#! F
e& o
&
& 3 & 8! " 6 & e a8 F# &
.'! !
! & ! &9
$#
& 3i & " 8 6 8 6
! + F
1.e
text input
!
!
2.3 text input & +
3.3 text input & & d +
4. 3 text input & alphanumeric character (numbers e& letters) e +
5.3 text input " h character 1 &9 3! username & password e length
restriction 1 a1Z " ! ; & & d &' + & !
7.i i
e < &8 !
i" !
.'! &&" +
ER 0
1\- :NONNON- EMPTY 06 :
:
e
e
common
i 6
.'! 6! !Y" + " 6 &! 3 &&+7 eiee
l e 8 .
F
! eiee
i!6#
!
! e& !d ! ! & skp .
+
01.// If the length of the element's string is 0 then display helper message
02.function notEmpty(elem, helperMsg){
03.if(elem.value.length == 0){
04.alert(helperMsg);
05.elem.focus(); // set the focus to this input
06.return false;
07.}
08.return true;
09.}
notEmpty function 3 eiee
input e 3
6A & ! F# F ! elem +
HTML text input ei '! 6A & skp strings e built in property F " 8 e +
length property 3 string e length return e
&a . elem.value 3 input e " string
. length 3#k + ' 9 a elem.value.length
elem.value.length 3 'i! ! + &
! + " & " &
6i a!1 helperMsg e + 3
&&+7 ! e alert p '" + 1 &&+7 #
+ F ei " ! ' e
1 + &
6o 3
u+!:
01.<script type='text/javascript'>
02.function notEmpty(elem, helperMsg){
03.if(elem.value.length == 0){
04.alert(helperMsg);
05.elem.focus();
06.return false;
07.}
08.return true;
09.}
10.</script>
11.<form>
12.Required Field: <input type='text' id='req1'/>
13.<input type='button'
14.onclick="notEmpty(document.getElementById('req1'), 'Please Enter a
Value')"
15.value='Check Field' />
16.</form>
p'!:
Required Field:
ER 0
1\- - 9$ i-,a 9[%f - & 06 n:
n:
3 u k.
.,! !m, zip . i" i!6#
k
" & 6! . 8 !Y" " + & 3 i!6#
k
+ & e& d" u6 + c 3 input e string
# + & 3 regular expression + c /^[09]+$/ e& " match & 3 string + & " an"6 k e character e +
01.// If the element's string matches the regular expression it is all
numbers
02.function isNumeric(elem, helperMsg){
03.var numericExpression = /^[0-9]+$/;
04.if(elem.value.match(numericExpression)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
u6 . " p " string +
e function 3 ! match ei function &&+ " 6 ! 3
string e 1 match F ! e & &&+ " 6 3!:
elem.value.match(e ! expression)
p'!:
Numbers Only:
ER 0
1\- - 9
i-,a $zR - & 06
n:
n:
ei isAlphabet function isNumeric function e " " & &"k '#8# t regular expression 6&" !
k t " match function &&+ F e ! 6& " &d & 3
" i string '#8# &d 8! &, " & lowercase e& uppercase u k t expression ! ;
&
01.// If the element's string matches the regular expression it is all
letters
02.function isAlphabet(elem, helperMsg){
03.var alphaExp = /^[a-zA-Z]+$/;
04.if(elem.value.match(alphaExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
u+!:
01.<script type='text/javascript'>
02.function isAlphabet(elem, helperMsg){
03.var alphaExp = /^[a-zA-Z]+$/;
04.if(elem.value.match(alphaExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
12.</script>
13.<form>
14.Letters Only: <input type='text' id='letters'/>
15.<input type='button'
16.onclick="isAlphabet(document.getElementById('letters'), 'Letters Only
Please')"
17.value='Check Field' />
18.</form>
p'!:
Letters Only:
ER 0
1\- - 9
$zR e$[ 9[%f 06 n:
n:
isAlphabet e& isNumeric function u et e function e #6n" F 3 d
i!6#
&d o u " 6 3!: isAlphanumeric
01.// If the element's string matches the regular expression it is numbers
and letters
02.function isAlphanumeric(elem, helperMsg){
03.var alphaExp = /^[0-9a-zA-Z]+$/;
04.if(elem.value.match(alphaExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
ER 0
1\- - CHARACTER e pPxRf $ LENGTH e $n-
mn:
$n-
mn:
Character !m &8! 98 &&+7 + field e p &' " 6 &
ap .
p" 8 3 3!
6! !! 3 zip . 5 +o u" k t 2 +o u" ! ! lengthRestriction function
"7 F ! # 8
k
.
i!6#
! minimum e& maximum Character e
!8! F
u+!:
01.<script type='text/javascript'>
02.function lengthRestriction(elem, min, max){
03.var uInput = elem.value;
04.if(uInput.length >= min && uInput.length <= max){
05.return true;
06.}else{
07.alert("Please enter between " +min+ " and " +max+ " characters");
08.elem.focus();
09.return false;
10.}
11.}
12.</script>
13.<form>
14.Username(6-8 characters): <input type='text' id='restrict'/>
15.<input type='button'
16.onclick="lengthRestriction(document.getElementById('restrict'), 6, 8)"
17.value='Check Field' />
18.</form>
p'!:
Username(6-8 characters):
ER 0
1\- - SELECTION p&W :
:
e ! madeSelection function &&+ + F &&+7 eiee
select input + " 3 ! &9 select
" 6 &! 6! 8! trick + & &&+7 ! p1 a6'! +37 prompt + & " 6 ! p1
a6'! + & select input- e F# " 6 ! 3!: "Please Choose"
01.function madeSelection(elem, helperMsg){
02.if(elem.value == "Please Choose"){
03.alert(helperMsg);
04.elem.focus();
05.return false;
06.}else{
07.return true;
08.}
09.}
u+!:
01.<script type='text/javascript'>
02.function madeSelection(elem, helperMsg){
03.if(elem.value == "Please Choose"){
04.alert(helperMsg);
05.elem.focus();
06.return false;
07.}else{
08.return true;
09.}
10.}
11.</script>
12.<form>
13.Selection: <select id='selection'>
14.<option>Please Choose</option>
15.<option>CA</option>
16.<option>WI</option>
17.<option>XX</option>
18.</select>
19.<input type='button'
20.onclick="madeSelection(document.getElementById('selection'), 'Please
Choose Something')"
21.value='Check Field' />
22.</form>
p'!:
Selection:
ER 0
1\- i
i
0
1\-:
0
1\-:
e! 6! & 3, &&+7 i i
&8 ! " & 6! " 6 &!
a&'i i i
an"6 k @ sign e& dot (.) 1 & 3 ! @ sign i i
e p1 Character + & ! e& ' 9 dot
(.) @ sign e 6 a&'i e Character e + &
Valid u+!:
Invalid u+!:
04.return true;
05.}else{
06.alert(helperMsg);
07.elem.focus();
08.return false;
09.}
10.}
u+!:
01.<script type='text/javascript'>
02.function emailValidator(elem, helperMsg){
03.var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
04.if(elem.value.match(emailExp)){
05.return true;
06.}else{
07.alert(helperMsg);
08.elem.focus();
09.return false;
10.}
11.}
12.</script>
13.<form>
14.Email: <input type='text' id='emailer'/>
15.<input type='button'
16.onclick="emailValidator1(document.getElementById('emailer'), 'Not a Valid
Email')"
17.value='Check Field' />
18.</form>
p'!:
Email:
ER 0
1\- 9$ e ah
&R:
p " e skp event F 3 ! onSubmit e
3! e &
&
! k + 3 ei event
0 & 1 return " & &
+ & ! 3 e
1 & " &
return " & &
+ & &
e
k t e ! Validator '! &&h" + F
08.<option>CA</option>
09.<option>TX</option>
10.<option>WI</option>
11.</select><br />
12.Username(6-8 characters): <input type='text' id='username' /><br />
13.Email: <input type='text' id='email' /><br />
14.<input type='submit' value='Check Form' /><br />
15.</form>
01.function formValidator(){
02.// Make quick references to our fields
03.var firstname = document.getElementById('firstname');
04.var addr = document.getElementById('addr');
05.var zip = document.getElementById('zip');
06.var state = document.getElementById('state');
07.var username = document.getElementById('username');
08.var email = document.getElementById('email');
09.
10.// Check each input in the order that it appears in the form!
11.if(isAlphabet(firstname, "Please enter only letters for your name")){
12.if(isAlphanumeric(addr, "Numbers and Letters Only for Address")){
13.if(isNumeric(zip, "Please enter a valid zip code")){
14.if(madeSelection(state, "Please Choose a State")){
15.if(lengthRestriction(username, 6, 8)){
16.if(emailValidator(email,"Please enter a valid email address")){
17.return true;
18.}
19.}
20.}
21.}
22.}
23.}
24.
25.
26.return false;
27.
28.}
059.return false;
060.}
061.}
062.
063.function isAlphanumeric(elem, helperMsg){
064.var alphaExp = /^[0-9a-zA-Z]+$/;
065.if(elem.value.match(alphaExp)){
066.return true;
067.}else{
068.alert(helperMsg);
069.elem.focus();
070.return false;
071.}
072.}
073.
074.function lengthRestriction(elem, min, max){
075.var uInput = elem.value;
076.if(uInput.length >= min && uInput.length <= max){
077.return true;
078.}else{
079.alert("Please enter between " +min+ " and " +max+ " characters");
080.elem.focus();
081.return false;
082.}
083.}
084.
085.function madeSelection(elem, helperMsg){
086.if(elem.value == "Please Choose"){
087.alert(helperMsg);
088.elem.focus();
089.return false;
090.}else{
091.return true;
092.}
093.}
094.
095.function emailValidator(elem, helperMsg){
096.var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
097.if(elem.value.match(emailExp)){
098.return true;
099.}else{
100.alert(helperMsg);
101.elem.focus();
102.return false;
103.}
104.}
105.</script>
106.
107.<form onsubmit='return formValidator()' >
108.First Name: <input type='text' id='firstname' /><br />
p'!:
First Name:
Address:
Zip Code:
State:
Username(6-8 characters):
Email:
Check Form
e
6! F 6#"! ! + " 6 " & " p " skp s +
"6 '! 3 6! 'k a 6k
1 e ! + c skp-e s i
" e $#c property e& function(3 method o &
+) &'; object
PSEUDO skp 01:
01:
01.<script>
02.var myString = "Hello Thur!";
03.
+
P\k
a
,k
/
-
'
~skp-estring
&
g~propertye$[function(r
methodo $
' )$\object
Pseudoskp .:
<script type="text/javascript">
var myString = "Hello Thur!";
//This is how you would access a property
var myProperty = myString.property;
//This is how you would access a function
var myFunctionResult = myString.function(argument1, argument2);
</script>
e
String Property?
String
property'
~
robject9m
R
ia
0
&/f
0P 0r-: String
objecte lengthproperty
i rString-echaracterse 9[%f
%
String Function?
+,-String9m
R a
-ia 0,
&String Function a
- u,W 0r-: +,-String Functione
nf
String0,
-
e$[
a
-g
%
?1
$k
-
0r%
-characterg
+,-
9$'
i-
e grt,a-R $m '
~ ei E[\-g
&String0 ,$&R-
- &
$ & -&a-String-R
r +,- %
& ,
-
String Functionse$[Properties:
ei anf
0P%
- '
i
$ +,-String0 ,6
-, Vz-, p&s,-, a1R e$[ 96R
&
,
- eiadvanced$m +,-
dynamico
$ 0, p&W 0k
t -&a- e V
& d u
n6
0P
$
skpString Length:
Advanced scripter0P pi - p
- ' 0rString 0- '
$ 0r- nre-webdeveloperesubmissionp&W
0r%
-usernamee n e
0$\character-nR- '-, E
& u6& '
$ $f$'W
01 9$
&
an& 0P +
Vstringelength 06
0-
skp .:
<script type="text/javascript">
var myString = "123456";
var length = myString.length;
document.write("The string is this long: " + length);
// Same thing, but using the property inside the write function
document.write("<br />The string is this long: " + myString.length);
</script>
pP\R-:
'
$:
String,$&R- '
Lengtho ,$&R- '
$:
Stringe ia character0rV , rP +,-length property 0E
n 0P&
$length property ,$&R- '
$
skp .:
<script type="text/javascript">
var myString = "123456";
document.write("The string is this long: " + myString.length);
myString = myString + "7890";
document.write("<br />The string is now this long: " + myString.length);
</script>
pP\R-:
p'!:
The string is this long: 6
The string is this long: 6The string is this long: 6
The string is this long: 6
sT[ ,$&R- '
LENGTH o ,$&R- '
$:
'
$:
s e F# character 3$ 6 3 6! length property n ! " & length property 6&" !
+ &
1.<script>
2.var myString = "123456";
3.document.write("The string is this long: " + myString.length);
4.
5.myString = myString + "7890";
6.document.write("<br />The string is now this long: " + myString.length);
7.
8.</script>
p'!:
The string is this long: 6
The string is now this long: 10The string is this long: 6
The string is now this long: 10
s &n
# " &k k" 3 a ! pg
$# 1! skpo " 3 6! a !
m s
3!: "Bobby Susan Tracy Jack Phil Yannis" e& p " !
& " 6 ! 6!
space character " " ! ' " 6 ! split function !"# !
# "7 & 3 p"& s
k
p E[\- 1
1
( SPLI T FUNCTI ON: DELI
DELI MI TER)
space character " " + & delimiter e& split function 3 s &k " e
&&+ p "
e
delimiter
k 3 ! ' F e
array " !"# ! e
n "7 split function e p1 3#k
+ c delimiter
9n- p E[\- e uP'-:
uP'-:
! s e u+! +
s &k + 3! e 5 e ! 5 + c delimiter
k &9
+ c split function array
! 3 mySplitResult e " 6
1.<script>
2.var myString = "123456789";
3.
4.var mySplitResult = myString.split("5");
5.
6.document.write("The first element is " + mySplitResult[0]);
7.document.write("<br /> The second element is " + mySplitResult[1]);
8.</script>
p'!:
The first element is 1234
The second element is 6789The first element is 1234
The second element is 6789
u6 u+ ! 5 delimiter + & 6Fn F " & e
! ! delimiter String + "
&"a" + 6&" character $#
n a' d 6:1 +
$ SPLI T FUNCTI ON e uP'-:
uP'-:
! split function e u+! "7 F 3 ! &d" + F 3 & ei '! s split 'i! + "
s "7 F ei u+ ! delimiter + c space character " "
01.<script>
02.var myString = "zero one two three four";
03.
04.var mySplitResult = myString.split(" ");
05.
06.for(i = 0; i < mySplitResult.length; i++){
07.document.write("<br /> Element " + i + " = " + mySplitResult[i]);
08.}
09.</script>
p'!:
Element 0 = zero
Element 1 = one
Element 2 = two
Element 3 = three
Element 4 = four
Element 0 = zero
Element 1 = one
Element 2 = two
Element 3 = three
Element 4 = four
6! 3 a!
i! 1 e& 3i iu ! e ap"'" 'b an# k + F 3 6! ! !$! i iu ! "7
1 &" 1k " & 6! search function e 8 & # & iu ! e ap"'" 'b$#
&
" 6 !
sT[ an9n- E[\E[\- ( JAVASCRI PT SEARCH
SEARCH FUNCTI ON)
ei s '! regular expression g+! e& s 67k 3 " regular expression e 1 match
F ! 3 match " & e
s e position
! & 3 match ! " & -1
! &
SEARCH FUNCTI ON REGULAR
REGULAR EXPRESSI ON:
e
! $#t# 6#! 3, 3! 6! regular expression "7 &! "! e
a&'i # slash e 8 1 & !
u+! +
01.<script>
02.var myRegExp = /Alex/;
03.var string1 = "Today John went to the store and talked with Alex.";
04.var matchPos1 = string1.search(myRegExp);
05.
06.if(matchPos1 != -1)
07.document.write("There was a match at position " + matchPos1);
08.else
09.document.write("There was no match in the first string");
10.
11.
12.</script>
p'!:
There was a match at position 45There was a match at position 45
k #!, regular expression F
'#8# e
! "Alex"
search function ei ! &&+
F 3 string1 e e
u6s" F ! e
' ! 1 match F
match e 6'! (45)
6 F
sT[ an9n- E[\E[\- ( STRI NG SEARCH FUNCTI
FUNCTI ON: ALTERNATI VE SEARCHES)
p'!:
There was a match at position 6There was a match at position 6
k #! regular expression e # ! F: Alex e& John
search function ei ! #
# " &&+ F e& F string1 e e$#
u6s" F !
un&& an9n- E[\E[\- e uP'- ( ADVANCED SEARCH FUNCTI
FUNCTI ON)
! u+ ! 8 6s & &I 3 & 3 search function &
01.<script>
02.var myRegExp1 = /Tom|Jan|Alex/;
03.var string1 = "John went to the store and talked with Alexandra today.";
04.var matchPos1 = string1.search(myRegExp1);
05.
06.if(matchPos1 != -1)
07.document.write("The first string found a match at " + matchPos1);
08.else
09.document.write("No match was found in the first string");
10.
11.var myRegExp2 = /Tom|Jan|Alex /;
12.var string2 = "John went to the store and talked with Alexandra today.";
13.var matchPos2 = string2.search(myRegExp2);
14.if(matchPos2 != -1)
15.document.write("<br />The second string found a match at " + matchPos2);
16.else
17.document.write("<br />No match was found in the second string");
18.
19.var myRegExp3 = /Tom|Jan|Alexandra/;
20.var string3 = "John went to the store and talked with Alexandra today.";
p'!:
The first string found a match at 39
No match was found in the second string
The third string found a match at 39
No match was found in the fourth stringThe first string found a match at 39
No match was found in the second string
The third string found a match at 39
No match was found in the fourth string
skp sT[
p9 ( JavaScr i pt St r i ng Repl ace)
:o!#
o!#
skp s a& k e e! k" F 3 8 6! s e " 3 ! 'b p " 6 ! p ' !
+ 8 6! ei
ee
e 8 6! &&+7 ! g+ " 6 !
s p '!:
'!
s p '! e #i 8 ! 3#k F:
1.SearchFor: ! 'b p + " 3 c e
+ " 6 s & $#
ek p'!
2.ReplaceText: ! 'b p + & e s e p !
p " 3c
01.<script>
02.var visitorName = "Chuck";
03.var myOldString = "Hello username! I hope you enjoy your stay username.";
04.var myNewString = myOldString.replace("username", visitorName);
05.
06.document.write("Old string = " + myOldString);
07.document.write("<br />New string = " + myNewString);
08.
09.</script>
p'!:
Old string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.Old
string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.
u6 3 c '#8# t p1 iu ! 6&" " + F e
+ c SearchFor 3#k 7&d" $#
ek p'! &&+
8 ei # " 6
p9 E[\-:
E[\-:0g
ek
p\ s e 6& " $#
ek p'! &&+ & e ! 61 + c '#8#
' ! 6& " s' &&+ &
01.<script>
02.var visitorName = "Chuck";
03.var myOldString = "Hello username! I hope you enjoy your stay username.";
04.var myNewString = myOldString.replace(/username/, visitorName);
05.
06.document.write("Old string = " + myOldString);
07.document.write("<br />New string = " + myNewString);
08.
09.</script>
p'!:
Old string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.Old
string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay username.
n "6o 3 c & iu ! 6&" ! +! $#
ek p'! e g&
p6 8 ei # 3
p9 E[\-:
E[\-:0g$
0g
ek
p\$#
ek p'! e ' 9 g i!6#
g&
ek p'! "7 " 6
01.<script>
02.var visitorName = "Chuck";
03.var myOldString = "Hello username! I hope you enjoy your stay username.";
04.var myNewString = myOldString.replace(/username/g, visitorName);
05.
06.document.write("Old string = " + myOldString);
07.document.write("<br />New string = " + myNewString);
08.
09.</script>
p'!:
Old string = Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay Chuck.Old string
= Hello username! I hope you enjoy your stay username.
New string = Hello Chuck! I hope you enjoy your stay Chuck.
3 + ' 9
+
! " + & 3 3 e 'b p " i k t s & 8! $#
ek p'! &&+ u"3 & p " i k t g&
$#
ek p'! &&+ u"
skp sT[ i-
1kaE E[\- u
( JavaScr i pt i ndexOf Funct i on)
:o!#
o!#
s '! indexOf e 8 6! 8! p ! #i 8 ! 3#k '! 8 6 &! p1 + c
e& 6 + c a
sT[ i-
1kaE E[\-:
E[\-:
i! .ka ' ! # 8 ! 3#k F 3 d"7 + c c
1.SearchString:3 6! " c!
2.Offset (c):
i! .ka '! u+!:
u+!
8! iue
s e www e 6'! & " 6
1.<script>
2.var aURL = "http://www.tizag.com/";
" + aPosition);
p'!:
The position of www = 7The position of www = 7
i! .ka '! a
u+!:
u+!
3 i! .ka '! &&+ p1 www e 6'! & " 6 "! p1 www &n 6 www e
6'! & " 6
01.<script>
02.var aURL = "http://www.tizag.com/www.html";
03.var aPosition = aURL.indexOf("www");
04.var secondPos = aURL.indexOf("www", aPosition + 1);
05.
06.document.write("The position of www = " + aPosition);
07.document.write("<br />The position of the second www =
08.
09.</script>
" + secondPos);
p'!:
The position of www = 7
The position of the second www = 21The position of www = 7
The position of the second www = 21
skp 0Ve
?$i+i1(
0Ve
?$i+i1( JavaScr i pt get El ement ByI d Tut or i al i n
Bangl a)
:o!#
o!#
skp:
skp .k n.$
e
n&ii.
.k n $
e
n&ii. (document.getElementById)
01.<script>
02.function notEmpty(){
03.var myTextField = document.getElementById('myText');
04.if(myTextField.value != "")
05.alert("You entered: " + myTextField.value)
06.else
07.alert("Would you please enter some text?")
08.}
09.</script>
10.<input type='text' id='myText' />
11.<input type='button' onclick='notEmpty()' value='Form Checker' />
p'!:
document.getElementById
i
k
eiee
e n
n
!
ei
e
&m 3 & eiee
!
n 6&" ! " 6 &! i! eiee
e 8
k
6&" !
" 6
p'!
Welcome to the site dude
3 + !
& eiee
e
n e
k
6&" ! 3n e!o !! & &&+7
k
6 k eiee
k
6&" ! " 6 & ! e
! +
iu i-,a
u, t
t
0k
,$&R
,$&R-:
01.<script>
02.function changeText2(){
03.var userInput = document.getElementById('userInput').value;
04.document.getElementById('boldStuff2').innerHTML = userInput;
05.}
06.</script>
07.<p>Welcome to the site <b id='boldStuff2'>dude</b> </p>
08.<input type='text' id='userInput' value='Enter Text Here' />
09.<input type='button' onclick='changeText2()' value='Change Text'/>
p'!
Welcome to the site dude
Enter Text
p'!
Welcome to the site dude