JavaScript Event returnValue Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Instance property

What You’ll Learn

The returnValue property is a deprecated boolean that tracks whether the event’s default action is still allowed. It defaults to true; set it to false to cancel. Learn how it mirrors the opposite of defaultPrevented and how to migrate—with five examples and try-it labs.

01

Kind

Instance property

02

Type

boolean

03

Default

true (allow)

04

Cancel

set false

05

Modern

preventDefault

06

Status

Deprecated

Introduction

Old event code often canceled a link or submit by writing event.returnValue = false (similar ideas also appeared as return false in some handlers). Modern code uses event.preventDefault() instead.

returnValue was adopted into the DOM mainly to support existing code. MDN recommends preventDefault() and defaultPrevented for new work.

💡
Beginner tip

Remember the polarity: returnValue === !event.defaultPrevented (when both reflect the same cancel state). Prefer reading defaultPrevented in new code.

Understanding Event.returnValue

An instance property that indicates whether the default action for this event has been prevented.

  • true (default) — default action is still allowed.
  • false — default action has been prevented / event canceled.
  • Writable (legacy) — setting false requests cancel (like preventDefault()).
  • Opposite of defaultPrevented — per MDN.
  • Deprecated — keep for legacy reading; use modern APIs in new code.
  • Web Workers — MDN notes it is available in workers.

📝 Syntax

JavaScript
event.returnValue
event.returnValue = false; // legacy cancel

Value

A boolean: true if the event has not been canceled; false if it has been canceled or the default was prevented.

Modern replacement

JavaScript
// Prefer this in new code:
event.preventDefault();
console.log(event.defaultPrevented); // true when cancel worked

⚡ Quick Reference

GoalLegacyModern
Cancel defaultevent.returnValue = falseevent.preventDefault()
Check canceledevent.returnValue === falseevent.defaultPrevented
Still allowed?event.returnValue === true!event.defaultPrevented
Needs cancelableYesYes
MDN statusDeprecated — prefer preventDefault / defaultPrevented

🔍 At a Glance

Four facts to remember about Event.returnValue.

Type
boolean

Legacy flag

Default
true

Allow action

Cancel
false

Block default

Status
deprecated

Prefer modern API

Examples Gallery

Examples follow MDN Event: returnValue. Learn the legacy flag, then migrate to modern methods.

📚 Getting Started

Read the default and cancel the legacy way.

Example 1 — Read the Default Value

Before any cancel, returnValue is typically true.

JavaScript
button.addEventListener("click", (event) => {
  console.log(event.returnValue); // true (default allowed)
});
Try It Yourself

How It Works

The flag starts allowing the default until something cancels it.

Example 2 — Legacy Cancel with returnValue = false

Setting false requests that the default action not run.

JavaScript
link.addEventListener("click", (event) => {
  event.returnValue = false; // legacy — prefer preventDefault()
  out.textContent =
    "returnValue = " + event.returnValue +
    "\ndefaultPrevented = " + event.defaultPrevented;
});
Try It Yourself

How It Works

Browsers wire this legacy path to the same cancel machinery as preventDefault().

📈 Opposite Flag & Migration

Compare with defaultPrevented and write modern code.

Example 3 — Opposite of defaultPrevented

After preventDefault(), the two booleans disagree (by design).

JavaScript
form.addEventListener("submit", (event) => {
  event.preventDefault();
  console.log("defaultPrevented:", event.defaultPrevented); // true
  console.log("returnValue:", event.returnValue);           // false
  console.log("opposite?", event.returnValue === !event.defaultPrevented);
});
Try It Yourself

How It Works

MDN: returnValue is the opposite of defaultPrevented.

Example 4 — Migrate Legacy to Modern

Side-by-side: old assignment vs preventDefault().

JavaScript
// Legacy (avoid in new code):
// event.returnValue = false;

// Modern:
if (event.cancelable) {
  event.preventDefault();
}
if (event.defaultPrevented) {
  console.log("Default was canceled the modern way");
}
Try It Yourself

How It Works

Check cancelable first in shared handlers, then call preventDefault().

🚀 Common Use Cases

  • Reading legacy handlers that set returnValue = false.
  • Migrating old cancel logic to preventDefault().
  • Teaching the polarity opposite of defaultPrevented.
  • Debugging mixed codebases during a cleanup pass.
  • Interviews: know the history, recommend the modern API.

🔧 How It Works

1

Event starts allowed

returnValue defaults to true.

Default
2

Cancel request

Legacy: set false. Modern: preventDefault().

Cancel
3

Flags update

returnValue becomes false; defaultPrevented becomes true.

State
4

Default blocked

If the event was cancelable, the browser skips the default action.

📝 Notes

  • MDN: Deprecated — show the banner; not Experimental / Non-standard on that page.
  • Present primarily to support existing code; prefer preventDefault() / defaultPrevented.
  • Available in Web Workers.
  • Not the same as HTMLDialogElement.returnValue.
  • Related learning: defaultPrevented, cancelable, cancelBubble, originalTarget, JavaScript hub.

Legacy / Deprecated Browser Support

Event.returnValue is marked Deprecated on MDN. Browsers may still support it for compatibility. Logos use the shared browser-image-sprite.png sprite. Prefer preventDefault() and defaultPrevented for new code.

Deprecated · Prefer preventDefault

Event.returnValue

Legacy boolean for whether the default action is still allowed. Opposite of defaultPrevented. Do not use in new apps.

Legacy Not for new apps
Google Chrome Supported for compatibility; prefer modern API
Legacy OK
Mozilla Firefox Supported for compatibility; prefer modern API
Legacy OK
Apple Safari Supported for compatibility; prefer modern API
Legacy OK
Microsoft Edge Chromium compatibility path
Legacy OK
Opera Follow Chromium compatibility
Legacy OK
Internet Explorer Historical legacy support
Legacy
Event.returnValue Deprecated

Bottom line: Read it to understand old code. For canceling defaults, always teach and ship preventDefault() + defaultPrevented.

Conclusion

Event.returnValue is a deprecated allow/cancel flag for the default action. Know that it is the opposite of defaultPrevented, then migrate every new cancel to preventDefault().

Continue with srcElement, defaultPrevented, cancelable, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use preventDefault() in new code
  • Check with defaultPrevented
  • Verify cancelable in shared handlers
  • Replace returnValue = false during refactors
  • Document legacy finds for your team

❌ Don’t

  • Introduce returnValue in new features
  • Confuse it with HTMLDialogElement.returnValue
  • Assume non-cancelable events can be blocked
  • Mix legacy and modern cancels without a migration plan
  • Treat deprecated as “recommended” because it still works

Key Takeaways

Knowledge Unlocked

Five things to remember about returnValue

A deprecated cancel flag—prefer preventDefault.

5
Core concepts
02

true

default allowed

Meaning
🚫03

false

default blocked

Cancel
🔁04

Opposite

of defaultPrevented

Compare
🎯05

Modern

preventDefault()

Prefer

❓ 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.
Yes. MDN marks Event.returnValue as Deprecated. Prefer event.preventDefault() to cancel and event.defaultPrevented to check. It is not labeled Experimental or Non-standard on that MDN page.
MDN says the value of returnValue is the opposite of defaultPrevented. If the default was prevented, defaultPrevented is true and returnValue is false.
No. Use preventDefault() and defaultPrevented. 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’s default action. HTMLDialogElement.returnValue is the dialog’s close return string—a different API.
Did you know?

Some very old patterns used return false from an onclick attribute handler to cancel defaults. That is a different (also legacy) convention. Today’s clear approach is always event.preventDefault() inside addEventListener.

Next: srcElement

Learn the deprecated target alias and migrate to event.target.

srcElement →

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.

5 people found this page helpful