Microsoft Edge: onclick event stops working?(Microsoft Edge:onclick 事件停止工作?)
问题描述
我在 Microsoft Edge 中的 (ASP.NET) Web 应用程序有奇怪的问题.
I have strange problems with my (ASP.NET) web application in Microsoft Edge.
在某个时刻,onclick
事件停止工作.页面上响应 onclick
事件的所有按钮都停止工作.在同一页面上,我有一些响应 onmousedown
事件的按钮并且它们继续工作.
At a certain point the onclick
event stops working. All buttons on the page that respond to the onclick
event stop working. On the same page I have some buttons that respond to the onmousedown
event and they keep working.
如果我刷新页面,问题就消失了.控制台中没有错误.我用其他浏览器(包括Windows 10下的IE11)没有这个问题.
If I refresh the page, the problem is gone. There are no errors in the console. I do not have this problem with other browsers (including IE11 under Windows 10).
你们中有人遇到过类似的问题吗?
Did any of you experience similar problems?
推荐答案
这不是一个完整的答案,因为它没有解决 为什么 click
事件不工作,但我觉得它属于这里,因为我和我的团队绝望地试图找到这个问题的答案.这似乎是 Edge 中的一个错误,我们尝试的所有解决方法都失败了,直到我偶然发现了上面的 @Come 评论.
This is not a complete answer, as it doesn't address why click
events don't work, but I feel it belongs here, as my team and I were hopelessly stuck trying to find an answer to this question. It appears to be a bug in Edge, and every workaround we tried failed, until I stumbled upon @Come's comment above.
解决方案是将我们所有的 click
事件更改为 mouseup
事件,模拟相同的行为.出于某种原因,即使 click
没有触发,也触发了 mouseup
.mousedown
也可以,但 mouseup
更恰当地模拟了 click
.
The solution was to change all of our click
events to mouseup
events, emulating the same behavior. For some reason mouseup
was triggered even when click
wasn't. mousedown
works as well, but mouseup
more-properly emulates click
.
var listenType = (navigator.userAgent.toLowerCase().indexOf('edge') != -1) ? 'mouseup' : 'click';
// ...
$("#my_element").on(listenType, function()
{
// ...
}
希望这对某人有所帮助!
Hopefully this helps someone!
这篇关于Microsoft Edge:onclick 事件停止工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Microsoft Edge:onclick 事件停止工作?


- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- addEventListener 在 IE 11 中不起作用 2022-01-01