禁用 Mobile Safari 中的“上一个”和“下一个”按钮
当焦点位于输入字段时,是否可以禁用 Mobile Safari 中的“下一个”和“上一个”按钮?我一直在尝试将所有字段设置为 readonly="readonly"
并分别删除/重新应用焦点/模糊属性的方法。它适用于某些领域,但不适用于所有领域。在某些情况下,感觉相当hacky/buggy。我可以普遍禁用上一个和下一个控件吗?这是针对 iPad 网络应用程序的,因此可访问性不是问题。
Is it possible to disable the 'next' and 'previous' buttons in Mobile Safari when focused on an input field? I've been trying the method of setting all fields to readonly="readonly"
and removing/reapplying the attribute on focus/blur respectively. It works for some fields, but not for all. In some cases, it feels rather hacky/buggy. Can I universally disable the previous and next controls? This is for an iPad web app, so accessibility is not an issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
到目前为止,对我来说最好的解决方案(基于 Jezen Thomas 解决方案)是将
focus
readonly
设置为input
和textarea
以及disabled
到select
,并在blur
上删除它们:只有一个缺陷是您在更改之前需要放弃焦点(例如单击背景)
input
/textarea
进行选择。但您可以轻松地在input
和textarea
之间更改焦点。So far the best solution for me (based on Jezen Thomas solution) is to set on
focus
readonly
toinput
s andtextarea
s anddisabled
toselect
s, and remove them onblur
:Only one flaw is that you need to drop focus (for example clicking on background) before changing from
input
/textarea
to select. But you can easily change your focus betweeninput
s andtextarea
s.我可以看到这张票是旧票,但上面建议的答案对我不起作用,因为 iPhone 在调用焦点事件之前打开选择选项列表。所以我使用了下面的代码,它对我来说很有魅力。
我的工作解决方案:
此解决方案禁用 iPhone 中的上一个和下一个按钮。如果您想更改仅针对特定输入元素的选择器,您只需在上面的代码中进行修改即可。
我只针对iPhone(也许你可以使用不同的条件来测试它是否是iPhone)。使用“touchstart”,因为它在“焦点”之前触发。在模糊时,我启用输入和返回选择字段。
希望这个答案有帮助。
I could see that this ticket is an old one, but the above proposed answer doesn't work for me as iPhone opens the select options list before the focus event is called. So I have used the below code and it worked like charm for me.
My working solution for this:
This solution disables prev and next buttons in iPhone. If you want to change the selectors targeting only the specific input elements, you just need to modify it in the above code.
I'm targeting only iPhone (may be you can use different condition to test if it's iphone or not). Used 'touchstart' as it gets triggered before the 'focus'. On blur, I'm enabling the input & select fields back.
Hope this answer helps.
我还没有亲自测试过这一点,但也许可以尝试使用
disabled
而不是readonly
。只读 -
无法修改只读字段。但是,用户可以使用 Tab 键选中它、突出显示它并从中复制文本。
禁用 - 禁用的输入元素无法使用且不可点击。
也许这就是您需要的差异?
I haven't personally tested this, but perhaps try
disabled
instead ofreadonly
.Readonly -
A read-only field cannot be modified. However, a user can tab to it, highlight it, and copy the text from it.
Disabled - A disabled input element is unusable and un-clickable.
Maybe this is the difference you need?
这是与 IOS 检测相同的脚本。
Here's the same script with the IOS detection.