..
The command throw to handle errors in JavaScript generates un'eccezzione within a try.
Let's see an example of code:
var x = prompt ("Enter a number between 5 and 10 ","");
try
{
if (x> 10)
throw "Errore1";
else if (x <5)
throw "Errore2";
}
catch (er)
{
if (er == "Errore1")
alert ("Error! not include more than 10");
if (er == "Errore2")
alert ("Error! not enter a number less than 5");
}
Execute the code and try to type a number in the range indicated NOT ...
| |
CSS (Course)
Web Design and Accessibility according to W3C CSS and XHTML. Starting from 29 €. |
| |
HTML (Course)
The markup language for the Web from 29 €. |
| |
Javascript (Course)
Complete guide to client-side scripting. From 39 €. |