在HTML输入字段之间切换输入方法 [英] Switching between input methods between HTML input fields

查看:85
本文介绍了在HTML输入字段之间切换输入方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有两个输入文本字段的HTML表单。



当用户从第一个字段切换到第二个字段时,我想自动切换用户的输入另一种方法,例如另一种语言。



我试图这样做的原因是我希望用户输入已知不同语言的内容每个字段。



我尝试过< input lang =JA/> 但似乎没有更改Safari for Mac或iOS上的输入法。



是否可以在HTML或JavaScript中基于每个文本字段更改输入法?

解决方案

输入方法由浏览器和用户控制。 lang 属性不会影响这一点,也没有其他HTML方式。从浏览器中通常使用的方法更改每个文档的输入方法(更少的每个字段)是没有用的(无论是静默地还是通过找出如何控制这些事情)。



在某些情况下,向用户提供特殊工具会有所帮助 - 不要覆盖输入法,而是提供其他可能性。例如,如果预期的语言是用拉丁字母写的,除了基本的a-z之外还有一些额外的字母,你可以有按钮输入它们(帮助人们使用没有方便的方法键入它们的键盘)。 / p>

可以构建充当输入法编辑器的控件,参见eg用于输入日语的 typd.in 。但这意味着在用户使用的输入法之上使用某些东西。


I have an HTML form with two input textfields.

When the user tabs from the first field to the second, I'd like to automatically switch the user's input method to a different one, say for a different language.

The reason I'm trying to do this is that I expect the user to type content in known different languages in each field.

I tried <input lang="JA" /> but that didn't seem to change the input method on Safari for Mac nor iOS.

Is it possible in HTML or JavaScript to change the input method on a per-textfield basis?

解决方案

Input methods are controlled by the browser and the user. The lang attribute does not affect this, and there is no other HTML way either. It would not be useful to change the input method on a per-document, still less per-field basis, from the method normally used in the browser and accepted by the user (either silently or by finding out how to control such things).

In some situations, it can be helpful to provide special tools to users—not to override input methods but to offer additional possibilities. For example, if the expected language is written in Latin letters with a few extra letters in addition to the basic a–z, you could have buttons for entering them (to help people using keyboards that have no convenient way to type them).

It is possible to build controls that act as input method editors, see e.g. typd.in for entering Japanese. But this means using something on top of the input methods that the user is using.

这篇关于在HTML输入字段之间切换输入方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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