01/Trieda2.html
1 <?xml version="1.0" encoding="windows-1250"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "DTD/xhtml1-strict.dtd">
4 <html>
5 <head>
6 <title>PC Space JavaScript a OOP</title>
7 <meta http-equiv="Author" content="Imrich BURANSKY" />
8 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1250" />
9 <script type="text/javascript" >
10 // Definicia triedy
11 // Konstruktor
12 function CKniha(autor, nazev, stran)
13 {
14 // Vlastnosti
15 this.autor = autor;
16 this.nazev = nazev;
17 this.stran = stran;
18 }
19 // Metody
20 CKniha.prototype.DajText = DajText;
21 // Definicia metody
22 function DajText (bHTML)
23 {
24 sText = "";
25 sBR = "\n";
26 if (bHTML)
27 { sBR = "<br />\n";
28 sText ="<h3>Kniha</h3>";
29 }
30 sText+="autor: " + this.autor + sBR;
31 sText+="nazev: " + this.nazev + sBR;
32 sText+="stran: " + this.stran + sBR;
33 return sText;
34 }
35 </script>
36 </head>
37 <body>
38 <script type="text/javascript" >
39 // Vytvorenie objektu
40 K1 = new CKniha("Imrich Buranský",
41 "HTML a DHTML Hotová řešení",
42 257);
43 // Pouzitie objektu
44 document.write(K1.DajText(true));
45 document.write("<br />\n");
46 document.write(K1.DajText(false));
47
48 </script>
49 </body>
50 </html>
51
52 <!-- ***** Výsledok *****
53
54 Kniha
55
56 autor: Imrich Buranský
57 nazev: HTML a DHTML Hotová řešení
58 stran: 257
59
60 autor: Imrich Buranský nazev: HTML a DHTML Hotová řešení stran: 257
61
62 -->