mfs1102 object oriented programming€¦ · try { //run some code here } catch(err) { //handle...

23
MFS1102 Object Oriented Programming

Upload: others

Post on 06-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

MFS1102 Object Oriented Programming

Page 2: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}
Page 3: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Page 4: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Page 5: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

<script type = "text/javascript"> <!–

window.print(; //-->

</script>

Page 6: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}
Page 7: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

<script type = "text/javascript"> <!–

window.printme(); //-->

</script>

Page 8: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Page 9: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Page 10: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}
Page 11: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

try{

var password = "123456";if ( password.length < 5 ){

throw "SHORT";} else if ( password.length > 10 ) {

throw "LONG";}

} catch ( err ) {if ( err == "SHORT" ){

alert ( "password must more than 5" );} else if ( err == "LONG" ) {

alert ( “password must less than 10" );}

}

Example

Page 12: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

try { //Run some code here }

catch(err) { //Handle errors here

}

Page 13: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

function message() { try{ showalert("Call showalert"); } catch(e) {

alert("error " + e); }

}

Example

Page 14: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Page 15: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Page 16: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Example

<html><head><script type = "text/javascript">

function myFunc() {var a = 50;alert("Value of variable a is : " + a );

}</script></head>

<body><p>Click the following to see the

result:</p><form>

<input type = "button" value ="Click Me" onclick = "myFunc();" />

</form></body>

</html>

Page 17: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Output

Page 18: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

<script type = "text/javascript"><!-- function myFunc() {

var a = 100; var b = 0;try {

if ( b == 0 ) {throw( "Divide by zero error." );

} else {var c = a / b;

}}catch ( e ) {

alert("Error: " + e );}

} //--> </script>

<p>Click the following to see the result:</p><form>

<input type = "button" value = "Click Me" onclick ="myFunc();" /></form>

Page 19: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Output

Page 20: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

Page 21: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

EXAMPLE<head>

<script type = "text/javascript">

<!–-

window.onerror = function (msg, url, line) {

alert("Message : " + msg );

alert("url : " + url );

alert("Line number : " + line ); }

//-->

</script>

</head>

<body>

<p>Click the following to see the result:</p>

<form>

<input type = "button" value = "Click Me"

onclick = "myFunc();" />

</form>

</body>

Page 22: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}

<img src="myimage.gif"

onerror="alert('An error occurred loading the image.')" />

Page 23: MFS1102 Object Oriented Programming€¦ · try { //Run some code here } catch(err) { //Handle errors here}