Catching the 'Object Expected' Error : Error Exceptions : Development : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Development   » [  Error Exceptions  ]   
 



Catching the 'Object Expected' Error

Please note that some example is only working under IE or Firefox.

/*

Learn How to Program Using Any Web Browser
by Harold Davis 

Apress CopyRight 2004

ISBN: 1590591135
*/

<HTML>
<HEAD>
<TITLE>Don't bug me, please! 
</TITLE>
</HEAD>
<BODY>
<H1>
<SCRIPT
function dosomething() { 

function goodFunc(){ 
   try 
      doSomething()
   
   catch (e) { 
      if (e.description == "Object expected") { 
         alert("Cannot find a function named doSomething!")
      
      else 
         alert ("Other error" + e.description)
      
   

</SCRIPT>
</H1>
<FORM>
<INPUT type=button value="Click Moi" onClick="goodFunc();">
</FORM>
</BODY>
</HTML>

           
       
Related examples in the same category
1.  Throwing an Error
2.  Catching an Error
3.  Controlling Script Errors
4.  An Exception Handling Example
5.  Nested Exception Handling
6.  Using the onError Event Handler
7.   Throwing String Exceptions
8.  Throwing an Error Object Exception
9.  A Custom Object Exception
10.  Use the try catch to handle exceptions
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.