关于IE10输入框focus后触发input事件的bug

工作中遇到的问题,谨记录以作备忘!!!

问题描述

IE10 在页面输入框上同时绑定了input以及foucs事件,当触发foucs事件的时候会触发input事件,导致我的第一次搜索无效。

注:本人只在IE8/IE10/Chrome等浏览器上进行测试,表现结果为:IE8、Chrome表现正常,IE10表现异常

暂时解决办法

在一番搜索之后,在这个异常反馈(注意这个链接得翻墙)中找到相同的表现,具体如下:

The JS code registers a listener on ‘input’ event for a <input type="text">.

What I find unexpected is that the event handler is triggered as soon as I focus the input field.

IE 11 triggers the handler when I either focus or leave (blur) the input field.
IE 10 triggers the handler only when I focus the input field.
IE 9, Google Chrome, Firefox and Opera do not trigger the handler unless the > user types something in the input or cuts/pastes in it.

这是给IE开发者提的反馈意见,回复是:

Thank you for the feedback. This issue has been fixed in Microsoft Edge. We’re not presently working on feature bugs in Internet Explorer outside of security-related issues.
Best Regards,
The Microsoft Edge Team

简而言之就是这是一个bug,会在Edge版本修复,同事在下面的建议中有这么一段话:

Note, this bug ONLY occurs when the input element has its placeholder attribute assigned. If it does not, IE 10/11 behave correctly.

只有当输入框上存在placeholder的情况下才会出现如此问题,因此项目中如果不是特别依赖placeholder可以将其暂时去掉。另外如果想要实现placeholder效果,可以使用另外的方式实现,这里不作讲述。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值