02/Princip.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>JS Výnimky - princíp</title>
7 <meta http-equiv="Author" content="Imrich BURANSKY" />
8 <meta http-equiv="Content-Type" content="text/html; charset=Windows-1250" />
9
10 </head>
11 <body>
12 <h2>Výnimky - princíp</h2>
13 <script type="text/javascript" >
14 sText = "";
15 for (x=6; x<=7; x++)
16 {
17 sText+= "<h3>x =" + x + "</h3>";
18
19 try
20 {
21 sText+="V bloku try ... pred if (x<7) throw <br />";
22 if (x<7) throw "Vyhodená výnimka";
23 sText+="V bloku try ... za if<br />";
24 }
25 catch (e)
26 {
27 sText+="V bloku catch: " + e + "<br />";
28 }
29 finally
30 {
31 sText+="V bloku finally<br />";
32 }
33 }
34
35 document.write(sText);
36
37 </script>
38 </body>
39 </html>
40
41 <!-- ***** Výsledok *****
42
43 Výnimky - princíp
44
45 x =6
46 V bloku try ... pred if (x<7) throw
47 V bloku catch: Vyhodená výnimka
48 V bloku finally
49
50 x =7
51 V bloku try ... pred if (x<7) throw
52 V bloku try ... za if
53 V bloku finally
54
55 -->