WWW-ohjelmointi Trainer Kit
460 530 625
1 HTML. HyperText Markup Language .........................................7 1.1 Internetin historiaa ..................................................7 1.1.1 Alku.................................................................7 1.1.2 Kehitys .............................................................8 1.1.3 Www:n läpimurto......................................................9 1.1.4 Nykyaika ja tulevaisuus .............................................9 1.2 Kuinka Internet toimii................................................10 1.2.1 Kommunikointi ......................................................10 1.2.2 Tiedonsiirto .......................................................11 1.2.3 Osoitteet ..........................................................12 1.3 URL...................................................................13 1.3.1 URL.................................................................13 1.3.2 Virtuaalinen osoite ................................................13 1.4 HTML:n historia ......................................................14 1.4.1 Rakenteiset dokumentit..............................................14 1.4.2 Versiot ............................................................14 1.4.3 Yhteisen määritelmän etu............................................15 1.4.4 Tulevaisuus ja XML..................................................15 2 Dokumentin rakenne .....................................................17 2.1 HTML-versio ..........................................................17 2.1.1 HTML 4.0 Strict.....................................................17 2.1.2 HTML 4.0 Transitional ..............................................17 2.1.2 HTML 4.0 Frameset...................................................18 2.2 HTML .................................................................18 2.3 HEAD .................................................................18 2.4 TITLE ................................................................19 2.5 META .................................................................20 2.6 BODY .................................................................21 2.7 H1-H6 ................................................................23 2.8 ADDRESS ..............................................................25 2.9 Kommentointi .........................................................26 3 Muotoilu ...............................................................27 3.1 Tekstin muotoilu .....................................................27 3.1.1 EM..................................................................27 3.1.2 STRONG..............................................................28 3.1.3 DFN.................................................................29 3.1.4 CODE................................................................29 3.1.5 SAMP................................................................30 3.1.6 KBD ................................................................31 3.1.7 VAR ................................................................31 3.1.8 CITE................................................................32 3.1.9 ABBR................................................................33 3.1.10 ACRONYM............................................................33 3.1.11 BLOCKQUOTE.........................................................34 3.1.12 Q .................................................................35 3.1.13 SUB ja SUP.........................................................36 3.2 Taustaväri............................................................36 3.3 Asettelu .............................................................37 3.4 Fontit ja viivat......................................................39 3.4.1 Korostuselementit TT, I, B, BIG, SMALL, STRIKE, S ja U..............39 3.4.2 Fonttielementit FONT ja BASEFONT ...................................40 3.4.3 Viivaelementti HR ..................................................41 3.5 Kappaleet ............................................................42 3.5.1 BR .................................................................43 3.5.2 P...................................................................43 3.5.3 PRE ................................................................44 4 Listat .................................................................46 4.1 Järjestämättömät listat UL ...........................................46 4.2 Järjestetyt listat OL ................................................47 4.3 Listan jäsen LI ......................................................49 4.4 Määritelmälistat: DL, DT, DD..........................................49 5 Taulukot................................................................51 5.1 TABLE.................................................................52 5.2 CAPTION ..............................................................56 5.3 Riviryhmät: THEAD, TFOOT, TBODY.......................................57 5.4 Sarakeryhmät: COLGROUP ja COL.........................................59 5.5 TR, TH, TD............................................................62 5.6 Taulukoiden käyttö ...................................................65 5.6.1 Asettelu ...........................................................65 5.6.2 Taulukon käyttö asettelussa ........................................65 5.6.3 Taulukko, joka sisältää linkkejä....................................67 6 Linkit ja ankkurit .....................................................69 6.1 Mitä linkit ovat?.....................................................69 6.2 A.....................................................................69 6.2.1 Ankkuri ............................................................72 6.2.2. Viittaaminen saman palvelimen hakemistoihin .......................75 6.2.3. Viittaaminen webissä sijaitseviin hakemistoihin ja tiedostoihin ...76 6. 3. BASE ...............................................................76 6.4 Eri URL-tyypit........................................................77 6.4.1 HTTP-protokolla ....................................................77 6.4.2 FTP-protokolla .....................................................78 6.4.3 TELNET-protokolla...................................................78 6.4.4 MAILTO-protokolla ..................................................79 6.5 LINK..................................................................81 6.6 Linkkityypit .........................................................83 7 Kehykset ...............................................................86 7.1 Mihin kehyksiä voi käyttää? ..........................................88 7.2 FRAMESET..............................................................90 7.3 FRAME.................................................................92 7.3.1 Kehyksen sisällön määritys..........................................93 7.3.2 Kehyksen nimeäminen.................................................93 7.3.3 Kehykseen viittaaminen..............................................94 7.3.4 Target-attributin erikoisarvot .....................................94 7.4 NOFRAMES..............................................................95 7.5 IFRAME ...............................................................95 8 Kuvat, sovelmat ja objektit.............................................97 8.1 IMG...................................................................97 8.1.1 Tekstin ulkoiset kuvat ............................................100 8.2 Kuvakartat...........................................................102 8.3 MAP ja AREA..........................................................102 8.3.1 MAP ...............................................................102 8.3.2 AREA...............................................................103 8.4 OBJECT...............................................................107 8.5 Kuvien asettelu .....................................................111 8.6 PARAM................................................................112 8.7 Mitä sovelmat ovat?..................................................113 8.7.1 APPLET ............................................................113 9 Tyylisivut.............................................................116 9.1 STYLE................................................................116 9.1.1 Elementtikohtainen tyylimäärittely.................................116 9.1.2 Tyylimäärittely otsikkolohkossa ...................................117 9.1.3 Erillinen tyylitiedosto............................................118 9.1.3.1 Tyylitiedoston liittäminen dokumenttiin..........................119 9.1.4 Tyyliluokat .......................................................120 9.2 Tyyliominaisuudet ...................................................121 9.2.1 Fonttien muotoiluominaisuudet .....................................122 9.2.1.1 font-family......................................................122 9.2.1.2 font-style.......................................................123 9.2.1.3 font-variant ....................................................124 9.2.1.4 font-weight .....................................................124 9.2.1.5 font-size .......................................................125 9.2.1.6 font.............................................................126 9.2.2 Värejä ja taustaa koskevat muotoiluominaisuudet....................127 9.2.2.1 color............................................................127 9.2.2.2 background-color.................................................127 9.2.2.3 background-image.................................................128 9.2.2.4 background-repeat ...............................................129 9.2.2.5 background-attachment ...........................................130 9.2.2.6 background-position..............................................130 9.2.2.7 background ......................................................132 9.2.3 Tekstin tasaus ....................................................132 9.2.3.1 word-spacing ....................................................132 9.2.3.2 letter-spacing ..................................................132 9.2.3.3 text-decoration..................................................133 9.2.3.4 vertical-align...................................................133 9.2.3.5 text-transform...................................................134 9.2.3.6 text-align.......................................................135 9.2.3.7 text-indent......................................................136 9.2.3.8 line-height......................................................137 9.2.4 Marginaalit .......................................................137 9.2.4.1 margin-top ......................................................138 9.2.4.2 margin-right.....................................................138 9.2.4.3 margin-bottom....................................................139 9.2.4.4 margin-left .....................................................139 9.2.4.5 margin...........................................................140 9.2.5 Reunukset..........................................................141 9.2.5.1 border-width ....................................................142 9.2.5.2 border-color ....................................................142 9.2.5.3 border-style.....................................................142 9.2.6 Oikotiet reunusten määrityksiin ...................................143 9.2.6.1 border-top ......................................................143 9.2.6.2 border-right.....................................................144 9.2.6.3 border-bottom....................................................144 9.2.6.4 border left .....................................................145 9.2.6.5 border...........................................................145 9.2.7 Padding-ominaisuudet...............................................146 9.2.7.1 padding .........................................................146 9.2.8 width..............................................................147 9.2.9 height.............................................................148 9.2.10 float ............................................................148 9.2.11 display ..........................................................149 9.2.12 list-style-type...................................................150 9.2.13 list-style-image..................................................150 9.2.14 list-style-position...............................................151 9.2.15 list-style .......................................................152 9.3 Yksiköt..............................................................152 9.3.1 Pituus.............................................................152 9.3.2 Prosentti..........................................................153 9.3.3 Värit..............................................................153 10 Lomakkeet ............................................................154 10.1 Kontrollit..........................................................154 10.2 FORM................................................................156 10.3 INPUT...............................................................158 10.3.1 Tekstikentät .....................................................160 10.3.2 Salasanakentät ...................................................161 10.3.3 Valintaruudut.....................................................162 10.3.4 Valintanapit .....................................................163 10.3.5 Tiedosto..........................................................165 10.3.6 Piilokentät ......................................................166 10.4 SELECT, OPTGROUP, OPTION............................................167 10.5 TEXTAREA ...........................................................171 10.6 BUTTON .............................................................173 10.7 LABEL...............................................................175 10.8 FIELDSET ja LEGEND..................................................176 10.9 Aktiivisuuden kohdistaminen ........................................178 11 JavaScript............................................................180 11.1 Mikä JavaScript on?.................................................180 11.2 Esimerkki hätäisille................................................181 11.3 JavaScriptin perusteet .............................................182 11.3.1 SCRIPT-elementti .................................................182 11.3.2 NOSCRIPT-elementti ...............................................183 11.3.3 Tapahtumankäsittely ..............................................183 11.3.3.1 Tapahtumat .....................................................184 11.3.3.2 Lomakkeen tietojen oikeellisuuden tarkistaminen.................185 11.3.4 Koodin sijoitus ..................................................187 11.3.5 Muuttujat ........................................................188 11.3.6 Vakiot............................................................190 11.3.7 Operaattorit .....................................................191 11.3.7.1 Sijoitusoperaattorit ...........................................192 11.3.7.2 Vertailuoperaattorit ...........................................193 11.3.7.3 Loogiset operaattorit...........................................194 11.3.8 Lausekkeet ja lauseet ............................................195 11.3.9 Ehtolause ........................................................195 11.3.10 Silmukat ........................................................198 11.3.11 Funktiot ........................................................201 11.3.12 Valmiit funktiot.................................................203 11.3.12.1 eval ..........................................................203 11.3.12.2 isFinite ......................................................203 11.3.12.3 isNaN..........................................................203 11.3.12.4 parseInt ......................................................204 11.3.12.5 parseFloat ....................................................204 11.3.12.6 Number ........................................................204 11.3.12.7 String ........................................................205 11.4 JavaScript ja oliot.................................................205 11.4.1 Johdatusta........................................................205 11.4.2 Olion luonti .....................................................206 11.4.3 Olion määrittely .................................................206 11.4.4 Olion metodit ....................................................207 11.4.5 Window-olio ......................................................208 11.4.6 Document-olio.....................................................211 11.4.7 History-olio .....................................................214 11.4.8 Navigator-olio ...................................................215 11.4.9 Location-olio.....................................................216 11.4.10 Math-olio........................................................217 11.4.11 String-olio .....................................................220 11.4.12 Date-olio........................................................223 11.5 Kuvien käyttö.......................................................225 11.5.1 Kuvat ja JavaScript ..............................................225 11.5.2 Images-kuvataulukko ..............................................225 11.5.3 Kuvan vaihto hiiren tullessa kuvan päälle ........................226 11.6 LiveConnect.........................................................227 11.6.1 Yleistä LiveConnectista ..........................................227 11.6.2 Java-sovelman hallinta JavaScriptistä.............................228 11.6.3 JavaScriptin hallinta Javasta ....................................229 11.6.4 Java-konsolin käyttö .............................................230 11.7 Turvallisuus .......................................................232 11.7.1 Saman alkuperän käytäntö .........................................232 11.7.2 Signeeratut skriptit .............................................232 12 CGI-ohjelmointi ......................................................234 12.1 CGI-ohjelmoinnin teoriaa ...........................................235 12.1.1 GET-metodi........................................................238 12.1.2 POST-metodi.......................................................240 12.1.3 Otsikkotiedot ....................................................240 12.1.4 Ympäristömuuttujat................................................241 12.1.5 Lomaketietojen käsittely..........................................242 12.1.6 Vastauksen tulostus...............................................242 12.1.7 Lomakkeet.........................................................243 12.1.8 Turvallisuus......................................................244 12.2 Perl-kielen perusteita .............................................246 12.2.1 Tietotyypit ......................................................251 12.2.2 Operaattorit .....................................................252 12.2.3 Ohjausrakenteet...................................................254 12.2.4 Merkkijonojen käsittely ..........................................259 12.3 Dynaamiset dokumentit ..............................................264 12.4 Lomakkeiden käsittely...............................................274 13 Julkaiseminen ........................................................292 13.1 Sivujen luominen ja hakemistot......................................292 13.2 Tiedostojen siirtäminen palvelin-koneelle...........................295 14 Yleiset attribuutit ..................................................299 14.1 Attribuutit.........................................................299 14.2 Tapahtumat .........................................................300