HTML
我正在处理一些包含
<div class="mycomment" dir="RTL">
<form method="get" action="{$self}">
<input type="hidden" name="Id" value="{$entry}" />
<textarea name="comment" class="commentarea"/></textarea>
<br />
<input class="button" type="submit" value="{$postlink}" />
</form>
</div>
在 RTL 模式下,字符串显示正确,但键盘导航不正确。具体来说,在浏览英语和阿拉伯语字符串部分时,它不遵循正确的顺序。
我有什么想法可以绕过或解决这个问题吗?
I am working with some HTML which contains a <textarea>
. Currently, I am testing the input of mixed LTR
and RTL
-based characters, such as "abcأبجABC"
.
<div class="mycomment" dir="RTL">
<form method="get" action="{$self}">
<input type="hidden" name="Id" value="{$entry}" />
<textarea name="comment" class="commentarea"/></textarea>
<br />
<input class="button" type="submit" value="{$postlink}" />
</form>
</div>
The display of the string is correct when in RTL
mode, however, the keyboard navigation is incorrect. Specifically, it does not follow the correct order when going through the English and Arabic string sections.
Any ideas how I might be able to bypass or fix this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不幸的是,根据规格,键盘导航可能是“正确的”。当尝试运行混合方向单词时,键盘快捷键(例如 Ctrl+>)要从一个单词跳转到另一个单词,开始根据字符的方向性改变方向在光标当前位置下 - 而不是从导航的角度将整个字符串视为单向。
不过,当您考虑计算机在输入混合模式句子时需要如何解释所有其他击键时,这是可以理解的。
如果您开始输入
LTR
字符,您希望它们从左到右移动(每个后续字符出现在最后一个字符的右侧)。但是,如果您开始输入RTL
字符,您会希望它们从右向左移动(每个后续字符都出现在最后一个字符的左侧)。可以这样想:
Ctrl+> 并不意味着“向右移动一个单词” - 它意味着“转到下一个单词” ”。在
RTL
环境中,下一个单词位于左侧 - 因此键盘会将您跳转到该方向。Next本质上与字节在内存中保存的顺序有关,而不是与字符显示的顺序有关屏幕。无论单词从屏幕的右侧还是左侧开始,字符都会按顺序保存在内存中,从单词的开头开始,到单词的结尾结束。
换句话说:Ctrl+> 按字节顺序移动,而不是按显示顺序移动。
所以 - 回到你如何克服它的问题......
除非你要编写一些相当复杂的 JavaScript(其中包含它自己的一系列挑战和麻烦)来改变键盘导航在你的盒子内的工作方式,否则没有什么好处方法来“修复”它。但是,如果您认为这会对您的客户产生负面影响,您可以尝试以下替代方案:
LTR
和RTL
文本,那么他们也可能在其他<中经常这样做/em> 应用程序。这意味着他们可能已经习惯了这组问题,因为这是一组标准问题。如果他们经常这样做 - 他们可能已经有了习惯的解决方法 - 而您更改它来修复它实际上可能伤害他们的生产力。Unfortunately, the keyboard navigation is probably "correct" according to the specifications. When attempting to run through mixed-direction words, keyboard shortcuts such as Ctrl+>, to jump from word to word, start changing direction depending on the directionality of the characters under the cursor's current position - rather than treating the entire string as uni-directional from a navigation standpoint.
This is understandable, though, when you consider how the computer needs to interpret all other keystrokes while typing in mixed-mode sentences.
If you start typing
LTR
characters, you expect them to travel left-to-right (with each subsequent character appearing to the RIGHT of the last). If you start typingRTL
characters, however, you expect them to travel right-to-left (with each subsequent character appearing to the LEFT of the last).Think of it this way:
Ctrl+> doesn't mean "go right one word" - it means "go to the next word". In an
RTL
environment, the next word is to the left - so the keyboard jumps you that direction.Next, in essence, relates to the order in which bytes are held in memory, rather than relating to the order in which characters are displayed on the screen. Whether a word starts on the right or left of the screen, the characters are held sequentially in memory, starting with the beginning of the word, and ending with the end of the word.
In other words: Ctrl+> travels in byte-order, rather than display-order.
So - back to your question of how to overcome it...
Unless you were to write some fairly complicated JavaScript (which contains its own set of challenges and troubles) to alter the way the keyboard navigation works within your boxes, there is no good way to "fix" it. However, you could try the following alternatives, if you feel it will negatively impact your customers:
LTR
andRTL
text in your application, it's also something they do regularly in other applications. This means they are probably used to this set of issues, because it's a standard set of issues. If they do it a lot - they probably already have workarounds which they're used to - and you changing it to fix it might actually hurt their productivity.哈哈,2010 年代真的很艰难。
只需添加这个 css 属性就可以了:
LOL, 2010s were really hard.
Just put this css property and you are good to go:
事实上你做不到。
作为一个说希伯来语的人,我可以告诉你,这方面存在很多问题,特别是当你混合 RTL 和 LTR 语言或有时混合数字时。
你无能为力。有时浏览器可以处理它,有时则不能。
例如,在 Chrome 中,当您使用 Ctrl 键在希伯来语文本中加快速度时,左右键的方向会变为相反。
Actually you cannot do it.
As an Hebrew speaking person I can tell you that there are lot's of problems in this area, especially when you mix RTL and LTR languages or sometimes numbers.
There is nothing you can do. Sometimes the browser can handle it and sometimes it can't.
For example in Chrome when you use Ctrl key to go faster inside an Hebrew text, the directions of the right and left keys change to their opposite.
您需要做的就是添加带有样式的 div:
All you need to do is add div with style: