事件 property returnValue indicates whether the default action for this event has been prevented or not. It is set to true by default, allowing the default action to occur. Setting this property to false prevents the default action.

注意: While returnValue has been adopted into the DOM standard, it is present primarily to support existing code. You should use preventDefault() ,和 defaultPrevented instead of this historical property.

句法

event.returnValue = bool;
var bool = event.returnValue;
					

A 布尔 value which is true if the event has not been canceled; otherwise, if the event has been canceled or the default has been prevented, the value is false .

The value returned by returnValue is the opposite of the value returned by defaultPrevented .

用法注意事项

returnValue was introduced into the DOM by Internet Explorer 6, and due to that browser's ubiquity became so commonly used that other browsers eventually implemented it as well. It has been adopted into the DOM specification, primarily to ensure that existing web content continues to function going forward.

New projects should generally avoid using returnValue , although they may if they choose to do so.

规范

规范 状态 注释
DOM
The definition of 'returnValue' in that specification.
实时标准 Added for legacy compatibility.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
returnValue 弃用 Chrome Yes Edge 12 Firefox No
不支持 No
Temporarily added in 63, removed in 64, briefly added in 65, then removed again while related compatibility issues are sorted out (see bug 1520756 ).
IE 6 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android No
不支持 No
Temporarily added in 63, removed in 64, briefly added in 65, then removed again while related compatibility issues are sorted out (see bug 1520756 ).
Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

元数据

  • 最后修改: