赛派号

红木排名前十名加工基地 Event.isTrusted Sample

Event.isTrusted Sample

Available in Chrome 46+ | View on GitHub | Browse Samples

The isTrusted read-only property of the Event interface is a Boolean that is true when the event was generated by a user action such as mouse click, and false when the event was scripted or invoked via dispatchEvent.

This new property is intended primarily for use by browser extensions, to determine if an event was dispatched by a script running in the main world or not.

Live Output JaScript Snippet var greenButton = document.querySelector('#greenButton'); var redButton = document.querySelector('#redButton'); greenButton.addEventListener('click', function(event) { if (event.isTrusted) { ChromeSamples.log('User clicked the green button. It is a trusted event.'); } else { ChromeSamples.log('User did NOT click the green button.'); } }); redButton.addEventListener('click', function() { greenButton.click(); });

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lsinopec@gmail.com举报,一经查实,本站将立刻删除。

上一篇 没有了

下一篇没有了