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
Fundamentals
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.
Concept
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.
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");
}
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.
LegacyNot for new apps
Google ChromeSupported for compatibility; prefer modern API
Legacy OK
Mozilla FirefoxSupported for compatibility; prefer modern API
Legacy OK
Apple SafariSupported for compatibility; prefer modern API
Legacy OK
Microsoft EdgeChromium compatibility path
Legacy OK
OperaFollow Chromium compatibility
Legacy OK
Internet ExplorerHistorical legacy support
Legacy
Event.returnValueDeprecated
Bottom line: Read it to understand old code. For canceling defaults, always teach and ship preventDefault() + defaultPrevented.
Wrap Up
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().
Mix legacy and modern cancels without a migration plan
Treat deprecated as “recommended” because it still works
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about returnValue
A deprecated cancel flag—prefer preventDefault.
5
Core concepts
⚠️01
Deprecated
legacy only
Status
✅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.