是什么触发了 mobile safari (iPad) 上的模糊事件
我有一个日期选择器控制器,当用户触摸屏幕上不是日期选择器的某个位置时,我想模糊该控制器。我遇到的问题是我不明白是什么触发了模糊事件。例如,如果用户触摸下个月,则会触发模糊事件,所以我想说,好的,如果 relatedTarget 是 datepicker 内的类(下个月),则显示下个月并且不要隐藏 datepicker,如果 relatedTarget 是不在日历上隐藏它。问题是相关目标 始终是未定义的。
所以我有两个问题:
- 什么会触发移动 Safari 上的模糊事件?
- 为什么 event.latedTarget 属性在移动版 Safari 中始终未定义?
I have a datepicker controller that I want to blur when the user touches somewhere on the screen that is not the datepicker. The problem that Im having with this is that I dont understand what triggers the blur event. For example if the user touches next month the blur event is triggered, so I would like to say, ok if the relatedTarget is a class inside the datepicker (next month) then show the next month and dont hide the datepicker, if the relatedTarget is not on the calendar hide it. The problem is that relatedTarget
is always undefined.
So I have two questions:
- What trigers the blur event on mobile Safari?
- Why is the event.relatedTarget property always undefined in mobile Safari?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这里找到:http://developer.apple.com/library/IOs/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5
以下注释:
iOS 注意:虽然不支持拖放,但您可以使用触摸事件产生相同的效果,如 Safari CSS 视觉效果指南中的“使用触摸拖动元素”中所述。
卸载事件可能无法按预期进行前后优化。请改用 pageshow 和 pagehide 事件。”
HTH
Found out here: http://developer.apple.com/library/IOs/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5
the following note:
"iOS Note: Although drag and drop are not supported, you can produce the same effect using touch events as described in “Using Touch to Drag Elements” in Safari CSS Visual Effects Guide.
The unload event may not work as expected for back and forward optimization. Use the pageshow and pagehide events instead."
HTH
老帖子,但也许对未来参考有帮助。
前几天遇到了同样的问题。关于你的第一个问题:什么触发了移动 Safari 上的模糊事件? ->如果发生触摸事件 (iPad/iPhone),则不会触发。
我通过在封闭的 div 上设置事件侦听器来处理它。与您(至少我)的预期相反,您想要听到的事件是“点击”。下面是简化的情况:
现在你的 js 可能看起来像这样:
Old post, but maybe helpful for futere reference.
Ran in to the same problem the other day. Regarding your first question: What triggers the blur event on mobile Safari? -> It's not triggered in case of a touch event (iPad/iPhone).
I dealt with it by setting an event listener on the enclosing div. Contradictionary to what you (at least I) might expect, the event you'll want to listen to is 'click'. Below the simplified situation:
Now your js might look like this: