01/Trieda1.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      function CKniha(autor, nazev, stran)
 12      {
 13        // Vlastnosti
 14        this.autor = autor;
 15        this.nazev = nazev;
 16        this.stran = stran;
 17        // Metody
 18        this.DajText = DajText;
 19        // Definicia metody
 20        function DajText (bHTML)
 21        {
 22          sText = "";
 23          sBR   = "\n";
 24          if (bHTML)
 25          {  sBR = "<br />\n";
 26             sText ="<h3>Kniha</h3>";
 27          }
 28          sText+="autor: " + this.autor + sBR;
 29          sText+="nazev: " + this.nazev + sBR;
 30          sText+="stran: " + this.stran + sBR;
 31          return sText;
 32        }
 33      }
 34    </script>
 35  </head>
 36  <body>
 37    <script type="text/javascript" >
 38      // Vytvorenie objektu
 39      K1 = new CKniha("Imrich Buranský",
 40                       "HTML a DHTML Hotová řešení",
 41                        257);
 42      // Pouzitie objektu
 43      document.write(K1.DajText(true));
 44      document.write("<br />\n");
 45      document.write(K1.DajText(false));
 46  
 47    </script>
 48  </body>
 49  </html>
 50  
 51  <!-- ***** Výsledok *****
 52  
 53  Kniha
 54  
 55  autor: Imrich Buranský
 56  nazev: HTML a DHTML Hotová řešení
 57  stran: 257
 58  
 59  autor: Imrich Buranský nazev: HTML a DHTML Hotová řešení stran: 257
 60  
 61  -->