admin管理员组文章数量:1357583
I want to measure the time between mousedown event and applying CSS active property without using any jQuery functions (pure Javascript). I found that there is onactive event but it is not supported by Opera (the browser on which I want to make this measurement). Actually this onactive event is supported only by IE (not sure which versions).
htmlElement.addEventListener('mousedown', function(){var timestamp = new Date().getTime() / 1000; console.warn('mouse down ', timestamp)})
htmlElement.addEventListener('DOMAttrModified', function(){var timestamp = new Date().getTime() / 1000; console.info('highlighted ', timestamp)})
This 'DOMAttrModified' event doesn't report when a button bees active.
I want to measure the time between mousedown event and applying CSS active property without using any jQuery functions (pure Javascript). I found that there is onactive event but it is not supported by Opera (the browser on which I want to make this measurement). Actually this onactive event is supported only by IE (not sure which versions).
htmlElement.addEventListener('mousedown', function(){var timestamp = new Date().getTime() / 1000; console.warn('mouse down ', timestamp)})
htmlElement.addEventListener('DOMAttrModified', function(){var timestamp = new Date().getTime() / 1000; console.info('highlighted ', timestamp)})
This 'DOMAttrModified' event doesn't report when a button bees active.
Share Improve this question edited Oct 27, 2019 at 8:51 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 6, 2012 at 13:05 NikolayNikolay 1851 gold badge5 silver badges14 bronze badges1 Answer
Reset to default 5:active
is a CSS pseudo-class, not a DOM attribute or property. It isn't possible or feasible to measure the time between mouse down and the time the :active
pseudo-class is set because of the single-threaded nature of GUI and code execution. Basically, by the time the mouse event fires, CSS and GUI updates are already queued and no event fires for when :active
is applied.
Still, I can't think of any valid reason for worrying about how long this process takes, you're probably better off forgetting about it and moving on.
本文标签: javascriptHTML element on active eventStack Overflow
版权声明:本文标题:javascript - HTML element on active event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744077897a2587087.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论