W3cubDocs

/Web APIs

ErrorEvent: filename property

Note: This feature is available in Web Workers.

The filename read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.

Value

A string.

Examples

window.addEventListener("error", (ev) => {
  console.log(`The error occur in file: ${ev.filename}`);
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
filename 10 12 27 11 6 18 27 11 6 1.0 4.4 6

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent/filename