事件
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. |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
returnValue
弃用
|
Chrome Yes | Edge 12 |
Firefox
No
|
IE 6 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes |
Firefox Android
No
|
Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
不支持
弃用。不要用于新网站。
见实现注意事项。