<html> <head> <script type="text/javascript"> function Gali() { for (var i=0;i<5;i++) { document.write("</br>This is crazy "+i + "<br />") } var x var myNames = new Array() myNames[1]="Alan" myNames[2]="Alan2" myNames[3]="Alan3" myNames[4]="Alan4" for(x in myNames) { document.write(myNames[x]+ "<br />") } }
var txt="" function trycatch() { try { adddlert("Welcome guest!") } catch(err) { txt="There was an error on this page.\n\n" txt+="Error description: " + err.description + "\n\n" txt+="Click OK to continue.\n\n" alert(txt) } }
function mythrow() { x = prompt("Enter a number between 0 and 10","") try{ if (x<0) throw "err1" if (x>10)throw "err2" } catch(myerr) { if (myerr=="err1") alert("number is less than 0") if (myerr=="err2") alert("number is greater than 10") }
}
</script> </head>
<body>
<form> <input type="button" onclick="Gali()" value="heello" >
</form>
<a href="http://www.galiwood.com" onmouseover="alert('An onMouseOver event');return false"> <img src="../images_movies/club.gif" width="100" height="30"> </a>
</br> <b>Try and Catch example</b> <input type="button" value="TryCatch" onclick="trycatch()" />
</br> <b>Throw example</b> <input type="button" value="Throw" onclick="mythrow()" />
</body> </html>
|