Skip to content

Commit

Permalink
Follow up to PR 31039: cross link for more information about onerror …
Browse files Browse the repository at this point in the history
…special behavior
  • Loading branch information
wbamberg committed Feb 15, 2024
1 parent 684163d commit 05d3204
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions files/en-us/web/api/window/error_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ Use the event name in methods like {{domxref("EventTarget.addEventListener", "ad
```js
addEventListener("error", (event) => {});

onerror = (event, source, lineno, colno, error) => {};
onerror = (message, source, lineno, colno, error) => {};
```

> **Note:** Due to historical reasons, `onerror` on `window` is the only event handler property that receives more than one argument.
> **Note:** For historical reasons, `onerror` on `Window` and {{domxref("WorkerGlobalScope")}} objects is the only event handler property that receives more than one argument.
## Event type

The event object is a {{domxref("ErrorEvent")}} instance if it was generated from a user interface element, or an {{domxref("Event")}} instance otherwise.

{{InheritanceDiagram("ErrorEvent")}}

## Usage notes
## Description

### Event handler property

For historical reasons, the `onerror` event handler property, on `Window` objects only, has different behavior from other event handler properties.
For historical reasons, the `onerror` event handler property, on `Window` and {{domxref("WorkerGlobalScope")}} objects only, has different behavior from other event handler properties.

Note that this only applies to handlers assigned to `onerror`, not to handlers added using `addEventListener()`.

Expand All @@ -56,7 +56,7 @@ When canceled, the error won't appear in the console, but the current script wil

The event handler's signature is asymmetric between `addEventListener()` and `onerror`. The event handler passed to `Window.addEventListener()` receives a single {{domxref("ErrorEvent")}} object, while the `onerror` handler receives five arguments, matching the {{domxref("ErrorEvent")}} object's properties:

- `event`
- `message`
- : A string containing a human-readable error message describing the problem. Same as {{domxref("ErrorEvent.message")}}.
- `source`
- : A string containing the URL of the script that generated the error.
Expand Down
4 changes: 4 additions & 0 deletions files/en-us/web/api/workerglobalscope/error_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ addEventListener("error", (event) => {});
onerror = (message, filename, lineno, colno, error) => {};
```

> **Note:** For historical reasons, `onerror` on {{domxref("Window")}} and `WorkerGlobalScope` objects is the only event handler property that receives more than one argument.
>
> For more details about this, see the page for the {{domxref("Window.error_event", "error")}} event on `Window` objects.
## Event type

A generic {{domxref("Event")}}.
Expand Down

0 comments on commit 05d3204

Please sign in to comment.