我正在构建一个Web应用程序,在输入文本框中我添加了dir =“auto”来自动检测文本方向,它可以在Chrome和Firefox中找到它们 .
当我稍后显示该文本时,我在容器中使用dir =“auto”(p,span等等) . 它在Chrome中工作正常但文本总是在Firefox中显示LTR . (如果我手动将其更改为dir =“rtl”,它可以在Firefox中使用,但我希望它是自动的)
我怎样才能解决这个问题 ?
不幸的是,Firefox(Gecko) does not support HTML5 dir attribute正确,它指定了元素的文本方向性 . 这是known bug,已在2012-11-26标记为已解决 .
它将是 implemented within Firefox20 (里程碑) . Firefox20在2013-02-18周上转向BETA .
您可以检测到客户端's default dir attribute by using gecko' s document.defaultView (MDN):
document.defaultView
// get ltr or rtl var dir = document.defaultView.getComputedStyle(document.documentElement,null);
1 回答
不幸的是,Firefox(Gecko) does not support HTML5 dir attribute正确,它指定了元素的文本方向性 . 这是known bug,已在2012-11-26标记为已解决 .
它将是 implemented within Firefox20 (里程碑) . Firefox20在2013-02-18周上转向BETA .
您可以检测到客户端's default dir attribute by using gecko' s
document.defaultView
(MDN):