onerroronerror*
*Contents  *Index  *Topic Contents
*Previous Topic: ondragstart
*Next Topic: onerror

onerror

Description

Fires when a scripting error occurs (for example, when there are security problems during the loading process or when there is a problem in the code).

Remarks

When programming in VBScript, you can create an event handler that receives event parameters by defining a subroutine having this form:

Sub window_onerror(message, url, line)
    window.event.returnValue=true

The line parameter is an integer specifying the line number at which the error occurred, url is a string specifying the URL of the document containing the error, and the optional message is a message string. Returning true for the event prevents the default error message for Internet Explorer from displaying.

The following example uses JScript.

function errortrap(msg,url,line){
    alert(msg);
    return true;
}
onerror=errortrap;

This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.

Applies To

window

See Also

onerror event for other objects


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.