From 05d3204389bacd3f2fe463ee2098d22d167e9a1b Mon Sep 17 00:00:00 2001 From: wbamberg Date: Wed, 14 Feb 2024 17:34:49 -0800 Subject: [PATCH] Follow up to PR 31039: cross link for more information about onerror special behavior --- files/en-us/web/api/window/error_event/index.md | 10 +++++----- .../web/api/workerglobalscope/error_event/index.md | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/files/en-us/web/api/window/error_event/index.md b/files/en-us/web/api/window/error_event/index.md index b6ae5a359b12dde..4d508aa4f32b5a0 100644 --- a/files/en-us/web/api/window/error_event/index.md +++ b/files/en-us/web/api/window/error_event/index.md @@ -17,10 +17,10 @@ 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 @@ -28,11 +28,11 @@ The event object is a {{domxref("ErrorEvent")}} instance if it was generated fro {{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()`. @@ -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. diff --git a/files/en-us/web/api/workerglobalscope/error_event/index.md b/files/en-us/web/api/workerglobalscope/error_event/index.md index 18c84edbc9ce49a..00dbc617da48dee 100644 --- a/files/en-us/web/api/workerglobalscope/error_event/index.md +++ b/files/en-us/web/api/workerglobalscope/error_event/index.md @@ -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")}}.