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 September 2021.
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 Standard # ref-for-dom-event-istrusted① |
瀏覽器相容性
BCD tables only load in the browser