- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人可以建议我与 JQuery 的 event.originalEvent 属性等效的 Javascript 跨浏览器(应支持 IE 11 和新版本的 Safari、Firefox、Chrome)吗?我尝试在 JS 代码中直接使用 event.originalEvent,它在 Chrome 浏览器上运行得很好,但在 Firefox 上却不行。
我需要此属性来区分元素上的实际鼠标单击和编程单击,但我没有使用 JQuery 的自由。
编辑:答案 here似乎正在做这件事。感谢大家的帮助。
最佳答案
这只是 native 事件
。检查其 isTrusted
属性:
The isTrusted read-only property of the Event interface is a boolean that is true when the event was generated by a user action, and false when the event was created or modified by a script or dispatched via dispatchEvent.
const div = document.querySelector('div');
div.addEventListener('click', (e) => {
if (e.isTrusted) console.log('manual click');
else console.log('script click');
});
setInterval(div.click.bind(div), 2000);
<div>click</div>
关于event.originalEvent 的 JavaScript 等价物?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50014470/
当我使用 .trigger() 触发粘贴事件时,随后捕获的粘贴事件没有 .originalEvent 属性。这是预期的行为吗?为什么? 参见示例 - http://jsfiddle.net/2uxEr
我目前沉浸在jQuery学习中心。我将从头到尾讲一遍。 我刚刚读过this paragraph : It's also important to note that the event object
我需要通过事件对象传递 originalEvent: MouseEvent { ... }。通常你可以这样做: $('#name').trigger({ type: 'mousedown',
这个问题在这里已经有了答案: event.originalEvent jQuery (3 个答案) 关闭 9 年前。 谁能帮我理解 originalEvent 在 JavaScript 中的用法?我
我正在尝试找出事件 originalEvent 的浏览器兼容性。并查看了各个地方,但找不到。 This answer的链接也没有信息。 我也 checkin 了can i use但也没有任何信息。 那
有人可以建议我与 JQuery 的 event.originalEvent 属性等效的 Javascript 跨浏览器(应支持 IE 11 和新版本的 Safari、Firefox、Chrome)吗?
我需要使用自定义操作覆盖自动完成焦点事件,并根据用户是否使用键盘而不是鼠标从列表中进行选择来执行某些操作。为此,我检查事件对象中的originalEvent.type,该对象应该包含执行的操作类型(k
一直在到处寻找如何使“sliderBar”上的这种触动在 iPad 上工作。我几乎用这个 http://www.the-xavi.com/articles/trouble-with-touch-eve
event.originalEvent.clipboardData.getData('Text').match(/[^\d]/)) 在上面的代码中,我不理解originalEvent和clipboar
在 a book ,处理mouseDown事件的代码是这样的: mousedownhandler: function (ev) { mouse.down = true; mouse.d
我正在编写一个简单的 JS/jQuery 脚本来检测鼠标滚轮滚动。 在大多数使用“mousewheel”的浏览器上,一切都按预期工作,但在 Firefox 上,我必须使用“DOMMouseScroll
出于某种原因,我不能使用 jQuery。 这是我的代码: document.addEventListener("touchstart", function(e) { e.preventDefa
我正在尝试通过以下帖子为 angularJS 创建拖放指令:http://jasonturim.wordpress.com/2013/09/01/angularjs-drag-and-drop/ 但我
有什么区别 event.originalEvent.dataTransfer.files 和 event.dataTransfer.files ??? 因为在拖放中,第二个代码不起作用,它是未定义的,
我是一名优秀的程序员,十分优秀!