如何在 Internet Explorer 中禁用自动日期和数字顺序翻转
以下 HTML,在 Internet Explorer 7/8/9 中显示时,日期显示为:
2011/31/05
在其他现代浏览器中,显示为:
05/31/2011
数据由数据库生成/存储,因此我们不能轻易修改它。我们也不想进行浏览器检测来尝试“修复”问题。很明显 IE 是故意这样做的,但是,我们希望以某种方式禁用该功能,因为它与其他浏览器不一致。 Microsoft Word 显然对具有相同数据的 RTF 文档执行了非常相似的操作。因此,它本身并不是一个“错误”,但我们仍然希望避免它并在嵌入它时显示日期。对于 1/2 等数字也执行此操作。
当我删除日期之前的十六进制实体: ف 时,行为停止。但文本可能是嵌入阿拉伯语句子中的日期,因此我们不希望它“自动翻转”日期,这可能会在稍后重新加载时造成严重的误解。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
</head>
<body>
<div align="right" dir="rtl">
<span dir="rtl">
<span style=" font-size:12pt">
ف 05/31/2011ظ
</span>
</span>
</div>
</body>
</html>
The following HTML, when displayed in Internet Explorer 7/8/9 displays the date as:
2011/31/05
In other modern browsers, it displays as:
05/31/2011
The data is generated/stored by a database, so we can't easily modify it. We'd rather also not do browser detection to try to "fix" the issue. It's clear IE is doing this intentionally, however, we'd like to disable the feature somehow as it's not consistent with other browsers. Microsoft Word apparently does something very similar with RTF documents with the same data. So, it's not a "bug" per se, but we'd still like to avoid it and show the date as we embedded it. It also does this for numbers such as 1/2.
When I remove the hex entity: ف preceding the date, the behavior stops. But the text could be a date embedded in an Arabic sentence, so we'd rather it not "auto flip" the dates, potentially causing serious misunderstanding when reloaded later.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
</head>
<body>
<div align="right" dir="rtl">
<span dir="rtl">
<span style=" font-size:12pt">
ف 05/31/2011ظ
</span>
</span>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将日期包装在跨度中并指定方向:
You could wrap the date in a span and specify the direction:
将其包裹在
不过,您必须在 css 中设置
pre
样式以匹配您当前的字体和大小。Wrap it in
<pre>
to keep the format as-is.You'll have to style
pre
in css to match your current fonts and size though.