JavaScript Event returnValue Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

In JavaScript, the returnValue property of the Event interface indicates whether the default action for this event has been prevented (MDN). It defaults to true (allow default).

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use event.returnValue. Start with this line.

JavaScript
event.returnValue = false;
CallWhat it does
event.returnValue = false;Primary signature.

Built into the browser. Read event.returnValue on an Event instance — no import required.

Library declarations
JavaScript
event.returnValue = false;

Parameters

ParameterDescription
preventDefault()Required. Modern cancel API

Return Value

Return ValueDescription
*Cancel default action

JavaScript Examples

Example 1 — Legacy returnValue = false

Old pattern: set the flag to cancel the default action.

JavaScript
const link = document.getElementById("link");

link.onclick = (event) => {
  event.returnValue = false; // deprecated
  console.log("default canceled (legacy)");
};
Try It Yourself

How It Works

  1. Click fires on the link.
  2. Set returnValue = false. Default navigation is blocked (legacy).
  3. Flag becomes false meaning “do not run the default.”
  4. Do not copy this into new projects — migrate next.

Example 2 — Prefer preventDefault()

Same intent with the modern API (MDN replacement).

JavaScript
const link = document.getElementById("link");

link.addEventListener("click", (event) => {
  event.preventDefault();
  console.log("default canceled");
  console.log(event.defaultPrevented); // true
});
Try It Yourself

How It Works

  1. Use addEventListener. Prefer this over assigning onclick.
  2. Call preventDefault(). Cancels the default when cancelable.
  3. Read defaultPrevented. Confirms the cancel succeeded.
  4. This is the code to keep in production.

Example 3 — Opposite of defaultPrevented

MDN: returnValue mirrors the inverse of defaultPrevented.

JavaScript
link.addEventListener("click", (event) => {
  event.preventDefault();
  console.log(event.returnValue);      // false
  console.log(event.defaultPrevented); // true
  console.log(event.returnValue === !event.defaultPrevented); // true
});
Try It Yourself

How It Works

  1. Cancel with preventDefault().
  2. defaultPrevented becomes true.
  3. returnValue becomes false. Legacy mirror of the same fact.
  4. Prefer reading defaultPrevented in new code.

Browser Support

Event.returnValue is marked Deprecated on MDN. Engines still implement it for compatibility, but new code should use preventDefault() and defaultPrevented. Also available in Web Workers (still deprecated).

✓ Deprecated

Event.returnValue

Legacy default-cancel flag — migrate to preventDefault() / defaultPrevented.

Legacy Deprecated
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
returnValue Prefer preventDefault

Bottom line: Supported for compatibility, not for new APIs. Prefer event.preventDefault(). See the MDN returnValue reference.

Frequently Asked Questions

It is a boolean Event property that indicates whether the default action for the event has been prevented. It defaults to true (allow default). Setting it to false prevents the default action (MDN).
MDN marks Event.returnValue as Deprecated. Prefer preventDefault() and defaultPrevented. It is not labeled Experimental or Non-standard on that MDN page. Also available in Web Workers.
MDN says returnValue is the opposite of defaultPrevented. If the default was prevented, defaultPrevented is true and returnValue is false.
No. Use preventDefault() to cancel and defaultPrevented to check. Learn returnValue only to read or migrate legacy code.
It only cancels when the event is cancelable (event.cancelable === true), similar to preventDefault(). Non-cancelable events cannot have their default blocked.
No. Event.returnValue is about canceling an event default. HTMLDialogElement.returnValue is the dialog close return string — a different API.

Next: srcElement

Learn the legacy alias of event.target.

srcElement tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful