Event: isTrusted 属性
注意:此功能在 Web Workers 中可用。
Event 接口的只读属性 isTrusted 是一个布尔值,当事件由用户代理生成时(包括通过用户操作和像 HTMLElement.focus() 这样的程序化方法),该值为 true;当事件通过 EventTarget.dispatchEvent() 派发时,该值为 false。唯一例外是 click 事件,在用户代理中,它会将 isTrusted 属性初始化为 false。
值
一个布尔值。
示例
js
if (e.isTrusted) {
/* The event is trusted */
} else {
/* The event is not trusted */
}
规范
| 规范 |
|---|
| DOM # ref-for-dom-event-istrusted① |
浏览器兼容性
加载中…