Event.defaultPrevented
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
概述
回傳一個布林值,表示事件的預設行為是否被取消,也就是事件物件是否曾執行 preventDefault()
方法。
備註:
You should use this instead of the non-standard, deprecated getPreventDefault()
method (see Firefox bug 691151).
語法
js
bool = event.defaultPrevented;
範例
js
if (e.defaultPrevented) {
/* the default was prevented */
}
規範
Specification |
---|
DOM # ref-for-dom-event-defaultprevented① |
瀏覽器相容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
defaultPrevented |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.