如何在 Internet Explorer 中禁用自动日期和数字顺序翻转

发布于 2024-12-16 17:00:59 字数 1138 浏览 2 评论 0原文

以下 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">
                &#1601;&nbsp; 05/31/2011&#1592;
            </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 技术交流群。

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

发布评论

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

评论(2

心安伴我暖 2024-12-23 17:00:59

您可以将日期包装在跨度中并指定方向:

ف  <span dir="ltr">05/31/2011</span>ظ

You could wrap the date in a span and specify the direction:

ف  <span dir="ltr">05/31/2011</span>ظ
情绪少女 2024-12-23 17:00:59

将其包裹在

 中以保持格式不变。

<pre>05/31/2011</pre>

不过,您必须在 css 中设置 pre 样式以匹配您当前的字体和大小。

pre {
    font-family:inherit;
    font-size:inherit
} 

Wrap it in <pre> to keep the format as-is.

<pre>05/31/2011</pre>

You'll have to style pre in css to match your current fonts and size though.

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