工作中遇到的问题,谨记录以作备忘!!!
问题描述
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
效果,可以使用另外的方式实现,这里不作讲述。