Event.isTrusted
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.
Event
介面的 isTrusted
唯讀屬性為一個布林值,若事件物件是由使用者操作而產生,則 isTrusted
值為 true
。若事件物件是由程式碼所建立、修改,或是透過 EventTarget.dispatchEvent()
來觸發,則 isTrusted
值為 false
。
語法
var bool = event.isTrusted;
範例
if (e.isTrusted) { /* The event is trusted. */ } else { /* The event is not trusted. */ }
規範
Specification |
---|
DOM # ref-for-dom-event-istrusted① |
瀏覽器相容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
isTrusted |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
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.