禁用Mobile Safari中的“上一个"和“下一个"按钮 [英] Disabling Previous and Next buttons in Mobile Safari

查看:102
本文介绍了禁用Mobile Safari中的“上一个"和“下一个"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当专注于输入字段时,是否可以在Mobile Safari中禁用下一个"和上一个"按钮?我一直在尝试将所有字段设置为readonly="readonly"并分别删除/重新应用focus/blur属性的方法.它适用于某些领域,但不适用于所有领域.在某些情况下,它感觉很hacky/越野车.我可以普遍禁用上一个和下一个控件吗?这是针对iPad Web应用程序的,因此可访问性不是问题.

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.

推荐答案

到目前为止,对我来说最好的解决方案(基于 Jezen Thomas 解决方案)是在focus readonly上设置为input s和textarea s和disabledselect s,然后在blur上将它们删除:

So far the best solution for me (based on Jezen Thomas solution) is to set on focus readonly to inputs and textareas and disabled to selects, and remove them on blur:

jQuery('input, textarea, select').on('focus', function() {
  jQuery('input, textarea').not(this).attr("readonly", "readonly");
  jQuery('select').not(this).attr("disabled", "disabled");
});

jQuery('input, textarea, select').on('blur', function() {
  jQuery('input, textarea').removeAttr("readonly");
  jQuery('select').removeAttr("disabled");
});

唯一的缺陷是,在从input/textarea进行选择之前,您需要放下焦点(例如,单击背景).但是您可以轻松地在input s和textarea s之间更改焦点.

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 between inputs and textareas.

这篇关于禁用Mobile Safari中的“上一个"和“下一个"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆