isTrusted 事件屬性
定義和用法
isTrusted 事件屬性返回布爾值,指示該事件是否受信任。
註釋:在 Chrome、Firefox 和 Opera 中,如果事件是由用戶調用的,則該事件是可信的,如果是由腳本調用的,則該事件是不可信的。在 IE 中,除了使用 createEvent() 方法创建的事件之外,所有事件都是可信的。
實例
確定特定事件是否可信:
function myFunction(event) { if ("isTrusted" in event) { if (event.isTrusted) { alert ("The " + event.type + " event is trusted."); } else { alert ("The " + event.type + " event is not trusted."); } } else { alert ("The isTrusted property is not supported by your browser"); } }
語法
event.isTrusted
技术細節
返回值: |
布尔值,指示事件是否可信。 可能的值:
|
---|---|
DOM 版本: | DOM Level 3 Events |
浏览器支持
表中的数字注明了完全支持该属性的首个浏览器版本。
属性 | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
isTrusted | 46.0 | 9.0 | 支持 | 不支持 | 33.0 |