Android Webkit 中的只读输入不起作用

发布于 2024-09-06 16:32:16 字数 351 浏览 1 评论 0原文

我的网页中有一个文本输入字段,用于收集日期(通过 jQuery 工具 .dateinput)。用户不需要能够在该字段中输入内容。单击该字段时会出现一个对话框。这是我的 Motorola Droid 上的一个问题,因为我不希望在单击该字段时出现软键盘。

我尝试过 input.blur() 焦点并将该字段设置为禁用和只读。将字段设置为禁用会产生不良副作用。将字段设置为只读适用于除 Android 浏览器之外的所有浏览器。浏览器似乎识别了“readonly”属性(或通过 javascript 读取),但该字段实际上并未变为只读。当您单击它时,软键盘仍然出现并允许您更改字段。

我认为这是 Android 浏览器中的一个错误。有人能想出一个聪明的替代方案吗?

I have a text input field in my web page that I am using to collect a date (via the jQuery Tools .dateinput). The user does not need to be able to type into the field. A dialog box appears when the field is clicked on. This is a problem on my Motorola Droid, because I don't want the soft-keyboard to appear when the field is clicked.

I have tried input.blur() on focus and also setting the field to disabled and readonly. Setting the field to disabled has undesired side effects. Setting the field to readonly works in everything but the Android browser. The browser seems to recognized the "readonly" attribute (or readOnly via javascript), BUT the field does not actually become readonly. When you click it, the soft keyboard still appears and allows you to change the field.

I suppose that this is a bug in the Android browser. Can anyone come up with a clever alternative?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雄赳赳气昂昂 2024-09-13 16:32:16

我使用了一种解决方法 - 因为我不需要在输入字段中进行实际编辑(像您一样,我弹出了一个日期选择器),所以我更改为具有类似样式的跨度。一旦你掌握了窍门,代码就变得微不足道了,而且它确实是特定于应用程序的,所以我没有任何真正的东西供你查看。

I used a workaround - since I didn't need to actually edit in the input field (like you, I was popping a date picker), I changed to a span with similar styling. The code is kind of trivial once you have the trick, and it's really app specific so I don't have any really for you to see.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文