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 2016年9月.
Event 接口的 isTrusted 只读属性是一个表示事件是否由用户行为生成的布尔值。当事件由用户行为触发时,为 true;当事件由脚本创建或修改,或通过 EventTarget.dispatchEvent() 派发时,为 false。
值
一个布尔值。
示例
js
if (e.isTrusted) { /* 事件可信 */ } else { /* 事件不可信 */ } 规范
| Specification |
|---|
| DOM> # ref-for-dom-event-istrusted①> |
浏览器兼容性
Loading…