HTML onunhandledrejection Event Attribute
Description
The onunhandledrejection event attribute is used on the <body> element (or as window.onunhandledrejection) and runs a script when a JavaScript Promise is rejected and no handler deals with the rejection, such as a missing .catch() or a try...catch around await.
The event is a PromiseRejectionEvent with the properties promise and reason (usually an Error). It is the Promise equivalent of window.onerror and is often used to send errors to a logging service. Calling event.preventDefault() stops the browser from printing the error to the console.
If a handler is attached to the promise later, the onrejectionhandled event fires.
Syntax
<body onunhandledrejection="script">
Values
- scriptThe name of the script to use when the event has been triggered.
Example
Browser Support
The following information will show you the current browser support for the HTML onunhandledrejection event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.
Desktop





Tablets & Mobile





