From 91459d0eb57711660c40c29e171d0cd30c1a9956 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:54:00 +0800 Subject: [PATCH] add docs for `ErrorEvent.lineno` --- files/en-us/web/api/errorevent/index.md | 2 +- .../en-us/web/api/errorevent/lineno/index.md | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 files/en-us/web/api/errorevent/lineno/index.md diff --git a/files/en-us/web/api/errorevent/index.md b/files/en-us/web/api/errorevent/index.md index d3fdd9bc7560fb5..9dd829f057efdf6 100644 --- a/files/en-us/web/api/errorevent/index.md +++ b/files/en-us/web/api/errorevent/index.md @@ -25,7 +25,7 @@ _Also inherits properties from its parent {{domxref("Event")}}_. - {{domxref("ErrorEvent.filename")}} {{ReadOnlyInline}} - : A string containing the name of the script file in which the error occurred. - {{domxref("ErrorEvent.lineno")}} {{ReadOnlyInline}} - - : An `integer` containing the line number of the script file on which the error occurred. + - : An integer containing the line number of the script file on which the error occurred. - {{domxref("ErrorEvent.colno")}} {{ReadOnlyInline}} - : An `integer` containing the column number of the script file on which the error occurred. - {{domxref("ErrorEvent.error")}} {{ReadOnlyInline}} diff --git a/files/en-us/web/api/errorevent/lineno/index.md b/files/en-us/web/api/errorevent/lineno/index.md new file mode 100644 index 000000000000000..8975a9de46930dc --- /dev/null +++ b/files/en-us/web/api/errorevent/lineno/index.md @@ -0,0 +1,31 @@ +--- +title: "ErrorEvent: lineno property" +short-title: lineno +slug: Web/API/ErrorEvent/lineno +page-type: web-api-instance-property +browser-compat: api.ErrorEvent.lineno +--- + +{{APIRef("HTML DOM")}}{{AvailableInWorkers}} + +The **`lineno`** read-only property of the {{domxref("ErrorEvent")}} interface returns an integer containing the line number of the script file on which the error occurred. + +## Value + +An integer. + +## Examples + +```js +window.addEventListener("error", (ev) => { + console.log("The error occur in line: " + ev.lineno); +}); +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}}