HTML & Javascript
HTML & Javascript
HTML & Javascript
m. k ik n aZ e, e. Ci k aS u a, T . kaiS au ri ,
T . Jvani a, l . p etri aS vi li
v e b d i z a i n i
HTML & JAVA SCRIPT
damxmare saxelmZRvanelo
damtkicebulia stu-s
saredaqcio-sagamomcemlo
sabWos mier
Tbilisi
2006
1
Markup Language) hiperteqstebis markirebis enis SesaZleblobebi,
stilebis Seqmna da gamoyeneba CSS (Cascading Style Sheet) enis
saSualebiT da Java script daprogramebis enis safuZvlebi.
saxelmZRvanelo gaTvaliswinebulia saqarTvelos teqnikuri
universitetis informatikisa da marTvis sistemebis fakultetis
studentebisaTvis da aseve mkiTxvelTa farTo wrisaTvis romlebic
dainteresebulni arian veb dizainiT.
Sesavali
rogorc cnobilia internetSi arsebuli nebismieri informacia,
romlTa daTvaliereba SesaZlebelia internet-brauzerebis saSualebiT,
2
inaxeba romelime Web serverze saitis saxiT. Web saiti Sedgeba Web
gverdebisagan, romelTa aRwera (Seqmna) da erTmaneTTan
dakavSireba xdeba html (Hyper Text Markup Language)
hiperteqstebis markirebis enis saSualebiT. html ar warmoadgens
programirebis enas, misi saSualebiT xdeba mxolod Web gverdebis
Seqmna da redaqtireba.
3
Navigator-Si da viZaxebT fails File+Open+Browse da virCevT
Sesabamis fails.
ZiriTadi mcnebebi
nebismieri html dokumenti Sedgeba internet-brauzerSi
gamosatani teqstisagan da mmarTveli simboloebisagan anu
tegebisagan.
tegi es aris brZaneba romelic moTavsebulia < da > simboloebs
Soris (mag. <p>) da gansazRvravs mis Semdeg warmodgenili teqstis
an grafikuli gamosaxulebis mdebareobas, zomas, fers da a. S.
rogorc wesi gamoiyeneba <tegis_saxeli> - gamxsneli da
</tegis_saxeli> - damxuravi tegi, romelTa saSualebiTac xdeba ama
Tu im brZanebis moqmedebis aris gansazRvra. (arsebobs
gamonaklisi tegebi romlebisTvisac ar gamoiyeneba damxuravi tegi)
4
TiTqmis yvela tegi Sedgeba ori nawilisagan:
sabazo tegebi
<HTML> ... </HTML> - aris Web dokumentis pirveli da bolo tegi,
romelic miuTiTebs rom aRniSnuli faili aris web gverdi
da ara ubarlo teqsti.
<HEAD> ... </HEAD> - saTauris bloki, sadac iwereba zogadi
informacia veb gverdis Sesaxeb.
<TITLE> ... </TITLE> - tegebs Soris iwereba dokumentis saxeli,
romelic Semdgom gamoisaxeba brauzeris saTauris velSi.
<BODY> ... </BODY> - tegi xsnis dokumentis tans, sadac
aRiwereba mTlianad dokumenti (web gverdis
Semcveloba).
5
<TITLE> dokumentis saxeli </TITLE>
</HEAD>
<BODY>
... dokumentis Semcveloba ...
</BODY>
</HTML>
mag:
<html>
<head>
<title>
My first page
</title>
</head>
<body>
Hello World!
</body>
</html>
Tu BODY tegSi ar miuTiTeT Web gverdis fonis feri,
avtomaturad irCevs TeTr fons. SesaZlebelia fonis Secvla Bgcolor
atributiT.
mag:
<html>
<title>My first page </title>
<body bgcolor=gray>
Hello World!
</body>
6
</html>
abzacis formatireba
<P> - tegi xsnis axal abzacs, sadac SeiZleba movaTavsoT
rogorc teqsti, aseve grafikuli gamosaxuleba.
ALIGN atributis saSualebiT xdeba mdebareobis gansazRvra.
am atributs SeiZleba mieniWos Semdegi mniSvnelobebi:
LEFT-marcxniv, CENTER-centri, RIGHT-marjvniv.
mag.: <P ALIGN=CENTER>
SeniSvna: ALIGN atributis sabazo mniSvnelobaa LEFT-marcxniv,
e.i. Tu gvinda abzacis marcxniv gasworeba, maSin SegviZlia
ar miuTiToT es atributi da <P ALIGN=LEFT>-is nacvlad
davwerT <P>.
7
<BLOCKQUOTE> - tegis saSualebiT xdeba teqstis tabulacia.
mag:
<html>
<title> My second page </title>
<body>
<p align=center>
AUTOBIOGRAPHY
</p>
<p align=left>
First name: Eka
<br>
Last name: Chikashua
</p>
<blockquote>
15.10.2001
</ blockquote >
</body>
</html>
teqstis formatireba
8
FONT – tegis saSualebiT xdeba Sriftis aRwera.
am tegs gaaCnia Semdegi atributebi:
FACE – Sriftis dasaxeleba,
SIZE – zoma,
COLOR – feri.
mag.: <font face=acadnusx size=4 color=red>
Sriftis sabazo mniSvnelobaa - Times New Roman. e.i. im
SemTxvevaSi Tu ar aris miTiTebuli Sriftis dasaxeleba avtomaturad
iwereba inglisurad.
aseve SesaZlebelia erTdroulad miuTiToT ramodenime Srifti.
<font face=”I Srifti, II Srifti ... ”> im SemTxvevaSi Tu
momxmareblis kompiuterze ar aris dayenebuli I Srifti, web gverdis
Sesabamis nawilis gamoitana moxdeba Semdegi SriftiT da. a.S.
mag.: <font face=”AcadNusx, DumbaNusx”>
Sriftis zomis sabazo mniSvnelobaa – 3.
arsebobs zomis miTiTebis ori xerxi: absolituri <font size=4>
da SedarebiTi <font size=+1>.
absolituri
mniSvneloba 1 2 3 4 5 6 7
SedarebiTi
mniSvneloba -2 -1 - +1 +2 +3 +4
mag:
<html>
<title> GTU </title>
<body>
<p>
Georgian Technical University <br>
<font size=5>Georgian Technical University</font> <br>
<font face=acadnusx>saqarTvelos teqnikuri universiteti </font> <br>
<font face=acadnusx size=5>saqarTvelos teqnikuri universiteti </font>
9
</p>
</body>
</html>
Sriftis stilebi
10
horizontaluri xazi
saWiroebis SemTxvevaSi web gverdis horizontaluri gayofa
SesaZlebelia `horizontaluri xazis~ gamoyenebiT, romlis aRwera
xdeba <HR> - Horizontal rule tegiT.
SesaZlebelia xazis zomebis miTiTeba Semdegi atributebis
daxmarebiT:
SIZE - xazis sisqe;
WIDTH – xazis sigrZe.
<hr width=70%>
<hr width=50% size=7>
11
SeniSvna: <HR> tegs ar gaaCnis damxuravi tegi.
e.i. </HR> - arasworia.
laboratoriuli samuSao
12
grafikuli obieqtis Casma WEB gverdze
Web gverdis srulyofisaTvis garda teqsturi informaciisa
gamoiyeneba grafikuli obieqtebi (*.gif an *.jpg formatis nebismieri
faili).
grafikuli failis HTML dokumentSi Casma xdeba Semdegi
tegiT:
<IMG SRC=sruli gza failamde>
im SemTxvevaSi Tu HTML dokumenti da grafikuli faili
moTavsebulia erT saqaRaldeSi failis sruli gzis nacvlad mieTiTeba
mxolod failis saxeli.
<IMG SRC=failis saxeli> e.i. <IMG SRC=*.GIF > an
<IMG SRC=*.JPG>
ganvixiloT SemTxvevei roca HTML dokumenti da grafikuli
faili ar aris moTavsebuli erT saqaRaldeSi.
picture3.g <img src=Image/New/picture3.gif>
if
picture2.g <img src=Image/picture2.gif>
if
Index.htm
l
picture1.g <img src=picture1.gif>
if
picture4.g <img src=../picture4.gif>
if
13
14
SesaZlebelia suraTis zomebis miTiTeba da suraTis Casma
CarCoSi Semdegi atributebis saSualebiT:
Width
Width=ricxvi an % - sigrZe;
Height=ricxvi an % - sigane.
Border=ricxvi – CarCos sisqe Height
...
15
<img src=emblem.gif align=top>
<font face=acadnusx>saqarTvelos teqnikuri universiteti
16
im SemTxvevaSi Tu gvinda suraTis gaswvriv davweroT
ramodenime striqoni, maSin suraTis aRmwer tegSi unda miuTiToT
atributi Align, romelsac SeiZleba miuTiToT Semdegi mniSvnelobebi
left-marcxniv an right-marjvniv.
mag.:
<html>
<title>gtu</title>
<body>
<img src=gtu.jpg align=left>
<p> <font face=acadnusx>
1922 wels Tbilisis saxelmwifo universitetSi Seiqmna
politeqnikuri fakulteti, romelic misi ganviTarebis safuZvelze 1928
wels calke gamoeyo saqarTvelos politeqnikur institutad
</p>
<p>1992 wels saqarTvelos politeqnikur instituts daerqva saqarTvelos
teqnikuri universiteti.
</font>
</p>
</body>
</html>
17
roca suraTis gverdiT aris ramodenime striqoni, pirvelad xdeba
suraTis aRwera, Semdeg teqstis mdebareobis <p align=left an center
an right>, Sriftis da a.S.
mag.:
<html>
<title>gtu</title>
<body>
<img src=gtu.jpg width=200 align=right>
<p align=center> <font face=acadnusx size=4>
saqarTvelos teqnikuri <br> universiteti
<hr>
</p>
<p>
acxadebs abiturientebis miRebas 2000-2001 saswavlo wlisaTvis
</font>
</p>
</body>
</html>
18
</p>
</body>
</html>
suraTidan teqstamde horizontaluri da vertikaluri daSorebis
gansazRvra xdeba Sesabamisad HSPACE da VSPACE atributebiT
mag.: <img src=gtu.jpg align=left HSPACE=25 VSPACE=10>
HSPACE=25
VSPACE=10
19
laboratoriuli samuSao
20
CamonaTvali da numeracia
CamonaTvalis aRwera xdeba <UL> ... </UL> (unordered list)
tegis saSualebiT.
CamonaTvalis TiTeuli wevri aRiwereba <LI> (List Item) tegis
saSualebiT.
CamonaTavlis saTauris miTiTeba xdeba <LH> (List Head)
tegiT.
mag:
<HTML>
<TITLE> Unordered Lists </TITLE>
<BODY>
<UL>
<font face=acadmtavr size=4> <b>
<LH> II kursi </b> </font>
<font face=acadnusx size=4> <i>
<LI> jg. 108040
<LI> jg. 108041
<LI> jg. 108042
<LI> jg. 108043
</i> </font>
</UL>
</BODY>
</HTML>
21
SesaZlebelia CamonaTvalis stilis arCeva TYPE atributis
saSualebiT
mag:
<HTML>
<TITLE> Unordered Lists </TITLE>
<BODY>
<OL>
<font face=acadmtavr size=4> <b>
<LH> II kursi </b> </font>
<font face=acadnusx size=4> <i>
<LI> jg. 108040
<LI> jg. 108041
<LI> jg. 108042
<LI> jg. 108043
</i> </font>
</OL>
</BODY>
</HTML>
22
SesaZlebelis numeraciis stilis arCeva TYPE atributis
saSualebiT
23
laboratoriuli samuSao
24
moZravi striqoni
moZravi striqonis aRwera xdeba <MARQUEE> tegiT,
romelsac gaaCnia Semdegi atributebi:
mag.:
<marquee width=400 height=50 bgcolor=gray>
<font face=acadmtavr size=4 color=white>
<b>saqarTvelos teqnikuri universiteti</b>
</font>
</marquee>
25
ALTERNATE - moZraoba meordeba
ganuwyvetliv urTierTsapirispiro
mimarTulebiT
mag.:
<marquee width=200 height=150 bgcolor=gray hspace=50
vspace=20 direction=up behavior=scroll loop=6 scrolldelay=100
scrollamount=25>
<font face=acadmtavr size=4 color=white>
<b>saqarTvelo</b></font>
</marquee>
laboratoriuli samuSao
26
cxrilebi
27
im SemTxvevaSi Tu ukve SeqmeniT ramodenime html
dokumenti, aucileblad waawydebodiT problemebs, Web gverdze
teqstisa da grafikuli obieqtebis sasurvel adgilze ganlagebis dros.
swored am problemis gadasaWrelad da Web gverdis mosawes-
rigeblad gamoiyeneba cxrilebi.
ganvixiloT tegebi, romelTa sasualebiTac xdeba cxrilis ageba.
rogorc viciT cxrili Sedgeba striqonebisagan da am striqonSi arsebuli
ujrebisagan. aqedan gamomdinare sxvadasxva tegis saSualebiT
xdeba calkeuli elementebis aRwera:
<TABLE> - cxrili, <TR> - striqoni, <TD> - ujra.
<TABLE>
<TR> <TD> . . . </TD> <TD> . . . </TD> <TD> . . . </TD> </TR>
28
2. Width=ricxvi an % - cxrilis sigrZe
<table border=2 width=200>
29
6. CellPadding=ricxvi - manZili ujris sazRvrebidan masSi
moTavsebul teqstsa Tu grafikul
gamosaxulebamde
<table border=2 width=200 height=100 CELLPADDING=15>
15pixels
ujrebis formatireba
im SemTxvevaSi Tu gvinda cxrilis calkeuli svetebi da
striqonebi iyos sxvadsxva zomis an gansxvavebuli foni hqondes
calkeul ujrebs Sesabamis atributebis gamoyeneba SesaZlebelia
ujris aRweris dros e.i. <TD> tegSi.
31
mdebareobis sabazo mniSvnelobebia align=left da
valign=middle
miTiTebebi:
1. cxrilis mdebareobis arCeva xdeva DIV tegiT: <div
align=left/center/right>
2. carieli ujris aRwera xdeba Semdegnairad: <td>
</td>
3. ujraSi gamoyenebuli tegebi ujris daxurvis Semdeg
avtomaturad wyveten funqcionirebas, aqedan gamomdinare
maTi daxurva aucilebeli ar aris.
mag.: <td><font face=acadnusx><i>siaxleebi:</td>
<td>News</td>
ujrebis gaerTianeba
cxrilis agebis dros vawydebiT ujrebis gaerTianebis
saWiroebas. amisaTvis gamoiyeneba Semdegi atributebi:
Colspan=ricxvi – svetebis gaerTianeba;
aRniSnuli ricxvi gansazRvravs gasaerTianebeli ujrebis
raodenobas..
32
<table border=2 width=200>
<tr> <td COLSPAN=3 align=center>Cell</td> </tr>
<tr> <td>Cell1</td> <td>Cell2</td> <td>Cell3</td>
</tr>
</table>
33
hiperkavSirebi
Web saitis Sesaqmnelad saWiroa calkeuli veb gverdis
erTmaneTTan dakavSireba, kavSiri SeiZleba ganxorcieldes teqstis
garkveul nawilze an grafikul gamosaxulebaze.
gamoiyeneba kavSiris gansaxorcielebis 4 tipi:
1. realuri misamarTis (URL) mqone web sait-
Tan dakavSireba
<A HREF=HTTP://misamarTi> xxx </A>
xxx-iT aRniSnul adgilze iwereba teqsti, romlis saSualebiTac
unda ganxorcieldes kavSiri, e.i. Sesabamis teqstze mausis daWeriT
moxdeba miTiTebul misamarTze arsebuli saitis gamoZaxeba.
mag.: me vswavlos stu-Si II kursze.
36
<html>
<title>sakurso</title>
<body>
<p align=center><font face=acadmtavr size=4><b> sakurso
samuSao </b></font>
</p>
<p> <font face=acadnusx size=3>
<a href=#1>Tavi1 </a>
<a href=#2>Tavi2 </a>
<a href=#3>Tavi3 </a>
</p>
<p>
<a name=1> <i>Tavi1 </i></a>
...
...
...
</p>
<p>
<a name=2> <i>Tavi2 </i></a>
...
...
...
</p>
<p>
<a name=3> <i>Tavi3 </i></a>
...
...
37
...
</p>
</body>
</html>
laboratoriuli samuSao
www.gtu.ge
netacad.gtu.ge
[email protected]
resursebi.html
scavleba.html
tanamshromlebi.html
siaxle.html
rekvizitebi.html
38
stilebis Seqmna da gamoyeneba
CSS - Cascading Style Sheet
CSS enis daxmarebiT SesaZlebelia veb gverdis sruli kontroli
gacilebiT martivad da metad funqcionalurad, vidre es HTML enis
saSualebiT xdeba.
arsebobs sami saxis stili:
1) INLINE STYLE SHEETS – Sida stili.
Sida stilis gamoyenebisas specialuri atributebi (css Tvisebebi)
iwereba pirdapir HTML tegSi.
mag.
HTML-Si <font face=acadnusx size=14pt color=blue> saqarTvelos
teqnikuri universiteti </font>
CSS-Si <font style="font-family: acadnusx; font-size: 14pt; color:
blue"> saqarTvelos teqnikuri universiteti
</font>
rogorc vxedavT Sida stilebis gamoyenebiT miviReT ufro didi
tegi vidre es HTML enis dros iyo. amitom maTi gamoyeneba xdeba
mxolod im konkretuli SemTxvevisaTvis, roca gvinda iseTi Tvisebis
gamoyeneba rac ar aris HTML-Si da aris CSS enaSi.
mag. asoebs Soris daSorebaa 7
<font style=letter-spacing: 7> saqarTvelos teqnikuri
universiteti </font>
39
am SemTxvevaSi stilis Tvisebebis aRwera xdeba veb
dokumntis dasawyisSi (<body>-mde) da gamoyeneba xdeba mTliani
dokumentis farglebSi.
mag.
<html>
<title>gtu</title>
<style type=text/css>
H1 {font-family: acadmtavr; font-size: 16; font-weight: bold}
H2 {font-family: acadnusx; font-size: 16; color: white}
body {background-color: gray}
</style>
<body>
<p align=center> <h1> saqarTvelos teqnikuri universiteti </h1>
</p>
<p align=center> <h2> saqarTvelos teqnikuri universiteti </h2>
</p>
</p>
</body>
</html>
40
.geo {font-family: acadnusx; font-size: 16; color: blue; font-
style: italic}
#bold {font-weight:bold}
</STYLE>
CSS struqtura
arsebobs stilebis gamocxadebis ramodenime meTodi:
1) selector {property: value}
selector aris Cveulebriv HTML elementi, romelis garkveul
Tvisebebs (property) eniWera konkretuli mniSvnelobebi (value).
mag.
<html>
<title>gtu</title>
<style type=text/css>
p {text-align: center}
body {background-color: blue}
h1 {font-family: acadmtavr; font-size: 16}
</style>
<body>
41
<p>
<h1> saqarTvelos teqnikuri universiteti </h1>
</p>
</body>
</html>
42
<html>
<title>gtu</title>
<style type=text/css>
.back {background-image: url(../image/pic.jpg); background-repeat:
no-repaet; background-position: center center}
.title { font-family: acadnusx; font-size: 16; font-weight: bold; text-
align: center}
#text {text-align: left; font-weight: normal; font-style: italic}
</style>
<body class=back>
<p class=title> saqarTvelos teqnikuri universiteti </p>
<p class=title id=text>acxadebs miRebas 2004-2005 saswavlo
wlisaTvis </p>
</body>
</html>
CSS Tvisebebi
Background Properties – fonis Tvisebebi
43
Tviseba mniSvnelobebi aRwera
background- color name fonis feri
color
background- url(*.jp) suraTis Casma
image url(*.gif) fonad
mag. url(pic.jpg)
background- repeat
repeat
repeat-x
repeat-y
no-repeat
44
arial arCeva
...
font-size small teqstis
medium zomis
large arCeva
ricxvobrivi
mniSvlelobebi:
mag: 10
12
20
30
...
font-style normal teqstis stili
italic
font-weight normal teqstis sisqe
bold
bolder
lighter
45
text- ricxobrivi abzacis
indent mniSvneloba dayeneba
mag: 20
letter- ricxobrivi asoebs Soris
spacing mniSvneloba daSoerba
mag: 5
word- ricxobrivi sityvebs
spacing mniSvneloba Soris
mag: 10 daSoreba
text- none
transform capitalize
uppercase
lowercase
46
border-left-color marcxena xazis feri
border-left -width sisqe
border-left –style stili
border-right-color marjvena xazis feri
border-right -width sisqe
border-right –style stili
www.alta.ge www.pasi.ge
47
[email protected]
www.complex-pro.com
about.html news.html firms.html
fonts.html
daprogramebis ena JavaScript
JavaScript-i daprogramebis ena gamoiyeneba HTML dokumentebis
Sesaqmnelad. enis mTavari aspeqti aris obieqtis cneba.
literalebi
48
martivi monacemebi razedac SeiZleba agebuli iqnas programa aris literalebi.
mTeli tipis mudmivebi SeiZleba mocemuli iqnas aTobiTi TeqvsmetobiTi, an
rvaobiTi formiT.
mTeli tipis aTobiTi mudmivebi SeiZleba warmodgenili iyos niSniT an
niSnis gareSe magaliTad 15,125, -156 +3546.
TeqvsmetobiTi ricxvebi Seicaven cifrebs 0-9-mde da asoebs a,b, c, d. e,f.
TeqvsmetobiTi ricxvebi iwereba ricxvis win simboloTi 0x, magaliTad 0x25,
0xa1, 0xff.
rvaobiTi ricxvebi Seicaven mxolod cifrebs 0-dan 7-is CaTvliT daiwereba
ase 03, 0543. 011.
aTwiladi ricxvebis Casawerad, rogorc yvela daprogramebis enaSi mZimis
nacvlad gamoiyeneba wertili. magaliTad, 123. 45, -56.789.
aTwiladi ricxvebis Casawerad gamoiyeneba eqsponencialuri forma
magaliTad, ricxvi 0,000000234 romelic SeiZleba ase warmovadginoT 2.34x10-7
JavaScript daprogramebis enaze Caiwereba 2.34e-7.
aTobiTi da mTeli mudmivebis garda arsebobs logikuri mudmivebi, romlebic
iReben mxolod or mniSvnelobas WeSmariti – true zogierT warmodgenaSi - 1,
mcdari- false – 0.
striqonuli literali warmoadgens simboloebis Tanmimdevrobas romelic
moTavsebulia ‘ ‘ an “ “ simboloebSi. magaliTad “ Sedegi” an ’Sedegi’. carieli
striqonuli cvladi aRiniSneba ‘ ‘ an “ ” simboloebiT.
cvladi
cvladebi gamoiyeneba monacemebis Sesanaxad. cvladebis aRwera xdeba
identifikatoris saSualebiT. identifikatori aucileblad unda iwyebodes laTinuri
alfavitis asoTi an gaxazvis simboloTi , Semdeg SeiZleba Cawerili iyos cifri an
gaxazvis simbolo. magaliTad test1, _my-test, test-1. cvladis tipi ganisazRvreba
maTSi Senaxuli monacemebis tipiT, monacemebis tipis SecvliT icvleba cvladis
tipi. cvladis gansazRvra xdeba sityviT var is aucileblad unda iyos gamoyenebuli
cvladebis aRwerisas an inicializaciisas. magaliTad,
var t1.
aq cvladis tipi ar aris gansazRvruli da is cnobili gaxdeba mas Semeg rac
mas mieniWeba mniSvneloba es ki xdeba miniWebis operatoris saSualebiT.
magaliTad:
var t1=345
am SemTxvevaSi t1 cvlads miniWebuli aqvs mniSvneloba 345.
cvladis mniSvneloba SeiZleba Seicvalos aseve miniWebis operatoriT.
miniWebis operatori SeiZleba gamoyenebuli iyos nebismier adgilze da SeuZlia
Secvalos ara marto monacemi aramed cvladis tipic.
miniWebis operators aqvs saxe:
a=b
49
sadac a- cvladia, b- gamosaxuleba.
dasaSvebia cvladebis Semdebi aRwera:
var n=3245
var x=2.89
var p=true
var s=”gamoTvla damTavrebulia”
n da x cvladebs aqvT ricxviTi tipi, p-s aqvs logikuri tipi, xolo s-s string.
JavaScript-Si gansazRvrulia aseve function tipi yvela standartuli
funqciisaTvis da aseve momxmareblis mier gansazRvruli funqciebisaTvis.
JavaScript-Si obieqtebs aqvT monacemTa tipi object.
cvladebis moqmedebis are
JavaScript-Si arsebobs ori tipis cvladebi globaluri da lokaluri. globaluri
cvladi gansazRvrulia mTel programaSi, lokaluri cvladi gansazRvrulia mxolod
konkretuli funqciis SigniT.
gamosaxuleba
gamosaxuleba Sedgeba literalebisagan, cvladebisagan, moqmedebaTa
niSnebisagan da frCxilebisagan. gamosaxulebis gamoTvlis Semdeg miiReba erTi
mniSvneloba, romelic SeiZleba iyos ricxvi, striqoni, an logikuri.
gamosaxulebaSi arsebul yvela cvladi unda iyos gansazRvruli. Tu
gamosaxulebaSi arsebul romelime cvlads ar aqvs mniSvneloba an ar aris
gansazRvruli maSin xdeba Secdomis dafiqsireba.
JavaScript-Si arsebobs null literali romelic aRniSnavs ganusazRvrel
mniSvnelobas.
nebismieri gamosaxuleba Sedgeba operandebis da operaciis niSnebisagan.
magaliTad, gamosaxuleba a*b -Si, a da b operandebia, * operaciis niSania.
operaciebi arseboben unaruli (erTadgiliani) da binaruli (oradgiliani).
gamosaxuleba Caiwereba +A, Tu + - unaruli operaciis aRniSvnaa, an A+B. Tu + -
binaruli operaciis aRniSvnaa.
gamoTvlili mniSvnelobis mixedviT, gamosaxuleba SeiZleba arsebobdes
ariTmetikuli, logikuri da striqonuli.
ariTmetikuli gamosaxulebis Casawerad gamoiyeneba Semdegi operatorebi:
+ Sekreba
- gamokleba
* gamravleba
/ gayofa
%naSTis miReba gayofis Sedegad
++ operandis mniSvnelobis gazrda 1-iT
-- operandis mniSvnelobis Semcireba1-iT
operaciebis Sesruleba xdeba marcxnidan marjvniv ariTmetikuli operaciebis
prioritetis mixedviT.
50
JavaScrip-Si gamoiyeneba operatorebis Caweris Semoklebuli forma:
X+=Y X=X+Y
X-=Y X=X-Y
X*=Y X=X*Y
X/=Y X=X/Y
X%=Y X=X%Y
JavaScript-Si gamoiyeneba Sedarebis Semdegi operaciebi. isini Sesrulebis
Sedegad iReben mxolod or mniSvnelobas true Tu Sedareba WeSmaritia an false
winaaRmdeg SemTxvevaSi. es operaciebia:
< naklebia
<= naklebia an tolia
== tolia
!= ar aris toli
> metia
>= metia an tolia
! operacia (logikuri ara) gamoiyeneba logikuri tipis operandebze. Tu a
operandis mniSvneloba true, maSin !a – mniSvneloba aris mcdari, Tu a operandis
mniSvneloba aris false , maSin !a - mniSvneloba aris WeSmariti. garda
aRniSnulisa logikuri operaciebis Sesasruleblad gamoiyeneba Semdegi logikuri
operaciebi:
&& (logikuri da), || (logikuri an)
maTi Sesrulebis Sedegi moyvanilia cxrilSi
A B A&&B A||B
51
inkrementi ++
dekrementi --
uaryofa !
unaruli minusi -
gamravleba *
gayofa, gayofa naSTis SenaxviT /,%
gamokleba -
Sedareba <,>,<=,>=
toloba ==
ar aris toli !=
logikuri da &&
logikuri an ||
miniWeba +, +=, -=, *=, /=, %=,
!=
52
length niSnavs rom daTvlili iqneba simboloebis raodenoba. magaliTad,
“2500” simboloebis raodenoba masSi tolia 4-is. length - sigrZe , misi tipi aris
ricxvi da striqoni.
53
</script>
</P> programis dasasruli</P>
</BODY>
</HTML>
PprogramaSi gamoyenebulia ori cvladi a da b. HTML gverdze gamotanis
formirebisaTvis gamoiyeneba write document obieqtSi
Tu JavaScript- s mxars ar uWers brauzeri, maSin gamoiyeneba tegi
<noscript>, es tegi moyveba <script> da </script> tegebs. Tu brauzeri mxars
uWers JavaScrip-s maSin es tegi ignorirdeba.
funqcia
programis Sedgenis dros gamoiyeneba logikurad damoukidebeli nawilebi
(qveprogramebi). programis yoveli nawili SeiZleba davyoT calkeul qveprogramad.
erTxel Seqmnili programa SeiZleba gamoviyenoT mravaljer, bevr enaSi qveprog-
ramis gageba realizdeba procedurebis, funqciis, modulebis da a.S daxmarebiT.
JavaScript-Si mTavari elementi aris funqcia.
funqcia esaa is samSeneblo bloki, romelic gamoiyeneba mravaljer.
funqciis aRweras aqvs saxe:
function F (V) {S}
sadac, F funqciis saxelia, romlis saSualebiTac xdeba masze mimarTva, V-
funqciis paramertebis (argumentebis) siaa, isini erTmaneTisgan gamoiyofian
mZimiT; s- funqciis tania, misi saSualebiT moicema is Sesasrulebeli moqmedeba,
romliTac unda miviRoT Sedegi.
funqciis aRwerisas unda gaviTvaliswinoT, rom is ar unda Seicavdes sxva
funqciis aRweras.
Tu funqciis aRweras aqvs saxe:
function F (v1,v2, ... vn) {s}
maSin funqciis gamoZaxebas unda qondes saxe:
F (e1,e2, ... ,en)
sadac, e1,e2, ... en– gamosaxulebebia romlebic faqtiur parametrebs
(argumentebs) gansazRvraven.
v1,v2, ..., vn parametrebs, romlebic funqciis aRweraSi aris miTiTebuli
qvia formaluri parametrebi. Tu funqcias ar aqvs parametrebi maSin mis aRweras
aqvs saxe:
function F () {s}
frCxilebis arseboba gamoZaxebis operatorSi aucilebelia anu funqciis
gamoZaxebas aseT SemTxvevaSi eqneba saxe:
F ().
SeniSvna: yvela gansazRvra da funqcia unda Setanili iyos <HEAD>
ganyofilebaSi.
54
ganvixiloT marTkuTxa samkuTxedis farTobis gamoTvlis programa funqciis
gamoyeenebiT, rodesac mocemulia misi kaTetebi.
<HTML>
<HEAD>
<TITLE> programa funqciis gamoyenebiT </TITLE>
<script language=”JavaScript”>
<!-- //
function ss (a,b)
{return a*b/2 }
// -->
</script>
</HEAD>
<BODY>
<P> furclis gamosaxva funqciiT</P>
<script>
<!- -
var a1=6; b1=9
var s= ss(a1,b1)
dokument.write (“miiReba mniSvneloba ”, s,”.”);
//-->
</script>
<P> furclis formirebis dasasruli </P>
</BODY>
</HTML>
funqciis tani Sedgeba mxolod erTi return operatoriT, romelic gansazRvravs
funqciis gamoZaxeba xdeba funqciis tanSi miniWebis operatoriT :
s=ss(a1,b1)
formalur a da b parametrs mieniWeba a1-is da b1-is faqtiuri mniSvneloba
da Sesruldeba funqciis tani. miRebuli mniSvneloba Tavsdeba dokumentSi Writen
operatoriT.
ganxilul SemTxvevebSi momxmarebels ar qonda SesaZlebloba Seetana
mniSvnelobebi da mieRo Sesabamisi Sedegi.
formebi
interaqtiuri dokumentebis umravlesoba (kavSiri Web gverdsa da
momxmarebels Soris) SeiZleba Seqmnili iyos formebis saSualebiT. es is sadgilia
sadac damalulia nebismieri brauzeris interaqtiuri SesaZleblobebi: teqsturi veli,
Rilakebi, gadamrTvelebi, siebi da a.S..
55
momxmareblis moqmedeba (mag. mausis Rilakze daWera) iwvevs garkveul
process. am procesis damuSaveba xdeba formebis elementebiT. procesis
damuSavebeli parametris saxeli iwyeba on TavsarTiT. magaliTad Click procesis
damuSavebis parametrs eqneba saxe onClick.
procesis parametrebi SeiZleba iyos operatorebi, procesis mniSvnelobebi ki
funqciis gamoZaxebebi, romlebic unda Sesruldes rodesac es procesi gaaqtiurdeba.
davuSvaT gvsurs SevqmnaT forma romelSic fuZe da simaRlis velebi
gamoiyeneba Sesabamisi mniSvnelobis Sesatanad. garda amisa formaSi SevqmnaT
Rilaki gamoTvla. am Rilakze daWeriT miviRebT samkuTxedis farTobs. aseT
SemTxvevaSi SeiZleba gamoyenebuli iyos Semdegi forma:
<FORM name=”form1”>
fuZe: <input type=”text” size=8 name=”st1”><hr>
simaRle: <input type=”text” size=8 name=”st2”><hr>
<input tupe=“button” value=gamoTvla
onClick=”maxval(document.form1.st1.value,
document.form1.st2.value,)”>
</FORM>
davweroT programa, romelic gamoTvlis samkuTxedis farTobs da sawyisi
mniSvnelobebis Sesatanad gamoviyenoT forma.
<HTML>
<HEAD>
<TITLE> samkuTxedis farTobis gamoTvla formiT </TITLE>
<script language=”JavaScript”>
<!-- //
function Fart(a,b)
{ var s=(a*b)/2;
document.write(“samkuTxedis farTobi aris”, s);
return s
}
// -->
</script>
</HEAD>
<BODY>
<p> samkuTxedis farTobis gamoTvla </P>
<FORM name=”form1”>
fuZe: <input type=”text” size=5 name=”st1”><hr>
simaRle: <input type=”text” size=5 name=”st2”><hr>
<input tupe=“button” value=gamoTvla
onClick=”Fart (document.form1.st1.value,
document.form1.st2.value,)”>
</FORM>
</BODY>
56
</HTML>
ganvixiloT Fart funqciis parametrebi dawvrilebiT.
HTML gverdis brauzeris mier interpretaciisas iqmneba JavaScript-is
obieqtebi. obieqtebs Soris urTierTkavSirs aqvs ierarqiuli struqtura. ierarqiis
yvelaze maRal doneze imyofeba Windows obieqti, romelic brauzeris fanjaras
warmoadgens. is aris “mSobeli” yvela danarCeni obieqtis. yvela furcels windows
obieqtis garda aqvs document obieqti. document obieqtis Tvisebebi gansazRvraven
TviT dokumentis Semcvelobas: fonis fers, Sriftis fers da a.S ganxilul magaliTSi
miRebuli forma warmoadgens document obieqtis nakadebs, xolo formis yvela
elementi warmoadgenen forma obieqtis nakadebs. obieqtze miTiTeba xorcieldeba
saxeliT, romelic mocemulia Html tegis name parametriT. samkuTxedis farTobis
mniSvnelobis misaRebad unda Sesruldes is konstruqcia romelic formis pirvel
velSia Setanili:
document.form1.st1.value
formaze mimarTvisas SeiZleba ar iyos miTiTebuli document obieqti.
ganxilul magaliTSi formis pirveli striqoni SeiZleba asec iyos Cawerili:
form1.st1.value
rodesac funqciaSi gadaicema martivi tipis monacemebi, magaliTad ricxvebi,
rogorc ganxilul magaliTSi, parametrris mniSvnelobis gadacema xorcieldeba
mniSvnelobiT. a formalur parametrs eniWeba faqtiuri parametris form1.st1.value
mniSvneloba, xolo b formalur parametrs form1.st2.value mniSvneloba. amis
Semdeg sruldeba funqciis tani.
situacia icvleba rodesac faqtiuri parametri aris obieqti. am dros amboben
parametris gadacema xorcieldeba miTiTebiT an dasaxelebiT
pirobiTi operatori if
mas aqvs saxe
if (piroba) {operatori an operatorebi}
if sagasaRebo sityvaa da misi miTiTeba aucilebelia. operatori muSaobs
Semdegnairad :
Tu mrgval frCxilebSi moTavsebuli piroba (misi mniSvneloba logikuri
tipisaa) WeSmaritia maSin Sesruldeba figurul frCxilebSi Cawerili operatori an
operatorebi, Semdeg ki marTva gadaecema figuruli frCxilebis Semdeg Caweril
operators. Tu piroba mcdaria maSin figurul frCxilebSi Cawerili operatorebi
ignorirdeba da marTva gadaecema figuruli frCxilebis Semdeg Caweril operators.
57
else
{operatori an operatorebi} Tu piroba mcdaria
58
<HTML>
<HTML>
<HEAD>
<TITLE> maqsimaluri da minimaluri mniSvnelobis gamoTvla
</TITLE>
<script language=”JavaScript”>
<!-- //
function maxmin (obj)
{ var a=Number (obj.num1.value);
var b=Number (obj.num2.value);
var ca=Number (obj.num3.value);
var l
var t
if (a>b) {l=b; t=a}
else
{t=b;l=a}
if(b>t) t=b
if(c<l) l=c
obj.resmax.value=t
obj.resmin.value=l
}
// -->
</script>
</HEAD>
<BODY>
<H4>maqsimaluri da minimaluri mniSvnelobis gamoTvla </H4>
<FORM name=”form1”>
ricxvi 1: <input type=”text” size=8 name=”num1”><hr>
ricxvi 2: <input type=”text” size=8 name=”num2”><hr>
ricxvi 3: <input type=”text” size=8 name=”num3”><hr>
maqsimaluri mniSvneloba tolia
<input tupe=“button” value=gansazRvra onClick=”maxminval(form1)”>
<hr>
<input type =”text” size=8 name=”resmax”>maqsimaluri mniSvneloba<hr>
<input type =”text” size=8 name=”resmin”>minimaluri mniSvneloba<hr>
<input type =”reset”>
</FORM>
</BODY>
59
<HTML>
3. SevadginoT programa romelic mocemul oTx a,b,c, d ricxvebs
Ddaaalagebs zrdadobis mixedviT
algoriTmi: Tavidan edareba ori a da b cvladebis mniSvnelobebi. Tu a meti
aRmoCndeba b-ze cvladebi cvlian mniSvnelobebs, Semdeg a-s
mniSvneloba dardeba c-s. Tu a>c-ze maSin cvladebi kvlav icvlian
mniSvnelobebs. da bolos aedareba d-s, saWiroebis SemTxvevaSi kvlav
xdeba cvladebis mniSvnelobebis Secvla. aseTnairad miiReba rom a-s
mniSvneloba 4-dan aris minimaluri. Semdeb b edareba c da d-s
saWiroebisas cvladebi cvlian mniSvnelobebs. bolos c edareba d-s.
<HTML>
<HEAD>
<TITLE>oTxi ricxvis mniSvnelobis dalageba</TITLE>
<script language=”JavaScript”>
<!-- //
function maxmin (obj)
{ var a=Number (obj.num1.value);
var b=Number (obj.num2.value);
var c=Number (obj.num3.value);
var d=Number (obj.num3.value);
if (a>b) {r=a; a=b; b=r}
if (a>c) {r=a; a=c;c=r}
if(a.d){r=a;a=d;d=r}
if (b>c) {r=b;b=c;c=r}
if (b>d){r=b;b=d; d=r}
if (c>d){r=c; c=d; d=r}
obj.num1.value=a
obj.num2.value=b
obj.num3.value=c
obj.num4.value=d
}
// -->
</script>
</HEAD>
<BODY>
<H4> oTxi ricxvis mniSvnelobis dalageba zrdadobis mixedviT </H4>
<FORM name=”form1”>
ricxvi 1: <input type=”text” size=10 name=”num1”><hr>
ricxvi 2: <input type=”text” size=10 name=”num2”><hr>
ricxvi 3: <input type=”text” size=10 name=”num3”><hr>
ricxvi 4: <input type=”text” size=10 name=”num4”><hr>
maqsimaluri mniSvneloba tolia
60
<input tupe=“button” value=dalageba onClick=”sortval(form1)”> <hr>
<input type =”reset” value= gasufTaveba>
</FORM>
</BODY>
<HTML>
ciklebi
masivebi
JavaScript-Si monacemTa Senaxvis da organizaciis erT-erTi yvelaze
moxerxebuli xerxia masivi. yvelaze martivi masivi SeiZleba warmovidinoT
erTganzomilebiani cxrilis saxiT. aseTi cxrilis TiToeuli sveti Seicavs monacemebs.,
amitom TiToeuli sveti danomrilia. svetebis danomrisaTvis ( masivis elementebis)
gamoiyeneba mkacrad gansazRvruli ricxviTi Tanmimdevroba, pirvel svets aqvs
nulovani nomeri. svetebis am nomrebs zogjer uwodeben indeqsebs. masivis
elementze mimarTvisaTvis saWiroa masivis saxeli da misi indeqsis saxeli.
masivis elementebi SeiZleba iyos nebismieri tipis, maT Soris obieqtebic.
JavaScript-Si erTi masivis elementebi SeiZleba iyos sxvadasxva tipis monacemebi.
masivi ganisazRvreba cvladis saSualebiT. amitom masivis Seqmnisas
cvlads eniWeba axali masivis obieqti. masivebi warmoadgenen JavaScript-Si
obieqtebs..
masivis gamosacxadeblad gamoiyeneba specialuri sityva new. misi
saSualebiT mexsierebaSi masivis elementebisaTvis gamoiyofa adgili. mas aqvs
araaucilebeli parametri Array (), romelSic SeiZleba miTiTebuli iyos masivis
elementebis saorientacio raodenoba. magaliTad
var USS = new Array (51)
61
am aRweris Sedegad masivisaTvis mexsierebaSi gamoiyofa adgili 51
elementisTvis. rom Seivsos masivi mis yovel elements unda mivaniWoT
mniSvneloba. masivis elementze mimarTvisaTvis gamoiyeneba specialuri
indeqsebi, Tavidan iwereba masivis saxeli, Semdeg kvadratul frCxilebSi saWiro
elementis indeqsi. USS masivis pirveli elementi iqneba:
USS[0].
rom mivaniWoT masivis elementebs konkretuli mniSvnelobebi unda
gamoviyenoT miniWebis operatori. magaliTad:
USS[0]=”Arizona”
USS[1]=”Arkansas”
da a.S
s a v a r j i S o e b i:
1. qvemoT CamoTvlili cvladebiis aRweridan da inicializaciidan romelia
Secdoma, axseniT ratomaa Secdoma da gaasworeT is:
a. my_name =”kate”
b. var how many=25
c. var zip=document.form1.zip.value
d. var 1address=document.nameform.address1.value
sarCevi
WEB gverdebis proeqtireba
Sesavali......................................................................................- 3 -
ra aris saWiro WEB gverdis Sesaqmnelad................................- 3 -
ZiriTadi mcnebebi......................................................................- 5 -
sabazo tegebi..............................................................................- 6 -
62
abzacis formatireba....................................................................- 8 -
teqstis formatireba......................................................................- 9 -
horizontaluri xazi.....................................................................- 11 -
laboratoriuli samuSao.............................................................- 13 -
grafikuli obieqtis Casma WEB gverdze...................................- 14 -
suraTisa da teqstis urTierTmedebareoba.................................- 16 -
laboratoriuli samuSao.............................................................- 21 -
CamonaTvali da numeracia.....................................................- 22 -
laboratoriuli samuSao.............................................................- 25 -
moZravi striqoni......................................................................- 26 -
laboratoriuli samuSao.............................................................- 28 -
cxrilebi.....................................................................................- 29 -
ujrebis formatireba...................................................................- 31 -
laboratoriuli samuSao.............................................................- 35 -
hiperkavSirebi..........................................................................- 36 -
laboratoriuli samuSao.............................................................- 40 -
63
gamoyenebuli literatura................................................................- 68 -
gamoyenebuli literatura
1. J. Neiderst "Learning Web Design" March 2001.
2. N. Heinle, M. Webb " Designing with JavaScript" June 2001.
3. М. Дмитриева JavaScript М.: 2002
4. Дэнни Гудман JavaScript М.: 2002
5. Вайк А.Р, Джиллиам Джейсон Д. JavaScript М.: 2004
64
koreqtori
kompiuteruli uzrunvelyofa
65