在IOS Safari中禁用选择选项 [英] Disable select option in IOS Safari

查看:147
本文介绍了在IOS Safari中禁用选择选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个表单,需要使用Javascript禁用选择框中的某些选项。它适用于所有浏览器,但不适用于IOS上的Safari(桌面Safari正确)。

I've implemented a form which needs to disable certain options in a select box using Javascript. It works fine in all browsers but not in Safari on IOS (Desktop Safari does it right).

我一直在寻找网络,但似乎没有人遇到这个问题到目前为止,所以我不确定它是Safari IOS限制还是我忽视的东西。

I've been looking around the web but it seems nobody had this problem so far, so I'm unsure whether it is a Safari IOS limitation or something I'm overlooking.

感谢您的帮助,
Miguel

Thanks for any help, Miguel

推荐答案

除了在开发iOS时删除已禁用的选项,别无选择。

There is no alternative but to remove the disabled options when developing for iOS.

对于iPhone,图片非常清晰:所有选择列表在所有情况下都被设置为点击轮,这些轮子不接受禁用选项。这在iPhone模拟器和实际的iPhone上都有显示。

For iPhone the picture is very clear: all select list are styled as click wheels in all circumstances, and these wheels do not accept disabled options. This is shown in the iPhone Simulator as well as on the actual iPhone.

对于iPad来说,图片更加混乱。 iPad模拟器会使禁用的选项变灰并真正使它们被禁用,就像移动Safari和桌面Safari一样。但是实际的 iPad(iPad 1,运行iOS 4.2.1,在我的情况下)会显示点击轮。

For iPad, the picture is more confusing. The iPad simulator does grey out the disabled options and really makes them disabled, just as mobile Safari and desktop Safari do. But an actual iPad (iPad 1, running iOS 4.2.1, in my case) will show you the click wheel.

所以做点什么在你的剧本的早期就像这样:

So do something like this early on in your script:

// check for ios device
nP = navigator.platform;      
if (nP == "iPad" || nP == "iPhone" || nP == "iPod" || nP == "iPhone Simulator" || nP == "iPad Simulator"){
    $('select option[disabled]').remove();
}

这篇关于在IOS Safari中禁用选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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