cloanto.comProducts & ServicesSupport

Knowledge Base
Previous Page
End of Page
TITLE

JavaScript Error Trapping

 

TOPIC

Q: Is there a way to suppress error messages, for example when an external action invoked from within MenuBox fails?

 

DISCUSSION

A: Yes. Errors can be trapped from within the MenuBox container in the same way they would be managed in a browser. This includes errors resulting from external code execution.

For example, you could add these three functions to your code:

function error_handler(msg,url,line)
{
 return true;
}

function error_trapping_on()
{
 window.onerror = error_handler;
}

function error_trapping_off()
{
 window.onerror = null;
}

Then just invoke error_trapping_on() at the beginning of the code to suppress all error dialogs that may otherwise occur. When an error occurs, the error_handler() function, which serves no purpose other than to be called in case of errors, will be invoked, and future actions invoked by the user will continue to run normally.

The above uses the onerror event, which is available in all versions of Windows supported by MenuBox. Alternatively, you may consider using the try... catch statement, which however requires at least Windows 98 SE, Windows Me, Windows 2000, or higher (or an older system with at least Internet Explorer 5 installed).

 

Article Information
Article ID:13-199
Platform:Windows
Products:MenuBox
Additional Keywords:ECMAScript, JScript
Last Update:2008-11-23
Your feedback is always appreciated. It is safe to link to this page.
Top of Page
Legal NotesPrivacy Notes