仅 IE9_有时_会忽略

发布于 2024-12-12 07:56:38 字数 3016 浏览 0 评论 0原文

我们正在开发一个大量使用 的网站(这是典型的 TYPO3 网站)。该网站是在子目录中开发的,稍后将被重新定位到顶级目录,因此我们无法轻易删除

我们的客户告诉我们,有时当她浏览新页面时,她得到的页面内容没有应用布局。我们对此进行了调试:仅在 IE9 中发生。查看日志我们发现,当错误发生时,IE9 尝试从错误的位置加载 CSS、JS 和所有图像:相对于当前 URL,而不是相对于 BASE HREF...进一步检查日志向我们显示IE8 用户也会受到影响,包括一些愚蠢的网络蜘蛛(对我们来说后者没有问题,谁在乎呢?)。

我们已经了解 IE8 推测下载器/前瞻解析器:http://blogs.msdn.com/b/ieinternals/archive/2009/07/27/bugs-in-the-ie8-lookahead-downloader.aspx

我确信我们没有遇到那里描述的错误:所有页面元素(包括第一个标题元素)都是从错误的位置加载的。此错误描述只有页面标题中的第二个和后面的元素受到影响。我们可以通过观察问题发生时的访问日志来证明这一点。

简单的重新加载即可修复该问题,将页面源代码与发生错误的页面源代码和未发生错误的页面源代码进行比较,显示绝对没有差异。只有IE受到影响,其他浏览器都没有问题。

标记是 标记中的第一个标记。我们尝试了所有可能的解决方案,但没有任何帮助。看来是IE的bug。

还有其他人遇到过这种情况并找到解决方法吗?我们还有其他几个使用 的网站,但我们无法在测试系统中重现此类行为 - 因此可能是某些东西触发或解决了此错误。但我分析了这些网站的日志,发现一些使用 IE8 的访问者甚至遇到了这个错误。

根据评论中的要求,这是我的 html 头的混淆示例:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>

<base href="http://client.site/cms/" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 
    This website is powered by TYPO3 - inspiring people to share!
    TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
    TYPO3 is copyright 1998-2011 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
    Information and contribution at http://typo3.com/ and http://typo3.org/
-->

<meta name="generator" content="TYPO3 4.5 CMS" />

<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_fad97d0aa7.css?1312295592" media="all" />
<link rel="stylesheet" type="text/css" href="fileadmin/css/styles.css?1319535102" media="screen" title="Standardstyles" />
<link rel="stylesheet" type="text/css" href="fileadmin/js/fancybox/jquery.fancybox-1.3.4.css?1310653643" media="all" />
<link rel="stylesheet" type="text/css" href="fileadmin/js/jqtransformplugin/jqtransform.css?1312810052" media="all" />

<script src="fileadmin/js/jquery-1.6.2.min.js?1310979164" type="text/javascript"></script>
<script src="fileadmin/js/jqtransformplugin/jquery.jqtransform.js?1312460310" type="text/javascript"></script>
<script src="typo3temp/javascript_93553eae97.js?1312462864" type="text/javascript"></script>

<link href="fileadmin/css/print.css" rel="stylesheet" media="print" type="text/css" />    
  <script src="/tools/formmailer.js" type="text/javascript" charset="utf-8"></script><title>Some title for the page</title>

</head>

We are developing a site which makes heavy use of <base href> (which is typical for TYPO3 sites). The site is developed in a sub directory and will later be relocated to the top directory so we can not easily remove <base href>.

Our client told us that sometimes when she browses the new pages she gets the page content without layout applied. We debugged this: It happens only in IE9. Looking at the logs we find that when the error happens, IE9 tries to load CSS, JS and all images consequently from the wrong location: relative to the current URL, not relative to the BASE HREF... Further inspection of the logs show us that IE8 users are also affected, including some dumb web spiders (no problem for us with the latter ones, who cares?).

We already know about IE8 speculative downloader / lookahead parser: http://blogs.msdn.com/b/ieinternals/archive/2009/07/27/bugs-in-the-ie8-lookahead-downloader.aspx

I'm sure we are NOT facing bugs described THERE: All page elements (including first header element) are loaded from the wrong location. This bug describe that only second and later elements from the page header are affected. We can prove this by watching the access logs when the problem occurs.

A simple reload fixes the issue, comparing the page source code with the bug occurring and without it occurring shows absolutely no difference. Only IE is affected, all other browsers are fine.

The <base href> tag is the first in the <head> tag. We tried every possible solution, nothing helped. Seems to be an IE bug.

Anyone else experiencing this and found a work around? We have several other sites using <base href> where we cannot reproduce such behavior in our test systems - so something is probably triggering or working around this bug. But I analyzed the logs of these sites and can see that some visitors using IE8 even there experience that bug.

As requested in the comments, here's an obfuscated example of my html head:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>

<base href="http://client.site/cms/" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 
    This website is powered by TYPO3 - inspiring people to share!
    TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
    TYPO3 is copyright 1998-2011 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
    Information and contribution at http://typo3.com/ and http://typo3.org/
-->

<meta name="generator" content="TYPO3 4.5 CMS" />

<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_fad97d0aa7.css?1312295592" media="all" />
<link rel="stylesheet" type="text/css" href="fileadmin/css/styles.css?1319535102" media="screen" title="Standardstyles" />
<link rel="stylesheet" type="text/css" href="fileadmin/js/fancybox/jquery.fancybox-1.3.4.css?1310653643" media="all" />
<link rel="stylesheet" type="text/css" href="fileadmin/js/jqtransformplugin/jqtransform.css?1312810052" media="all" />

<script src="fileadmin/js/jquery-1.6.2.min.js?1310979164" type="text/javascript"></script>
<script src="fileadmin/js/jqtransformplugin/jquery.jqtransform.js?1312460310" type="text/javascript"></script>
<script src="typo3temp/javascript_93553eae97.js?1312462864" type="text/javascript"></script>

<link href="fileadmin/css/print.css" rel="stylesheet" media="print" type="text/css" />    
  <script src="/tools/formmailer.js" type="text/javascript" charset="utf-8"></script><title>Some title for the page</title>

</head>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

意犹 2024-12-19 07:56:38

我们发现:当从服务器返回的 HTML 文件包含 UTF-8 BOM 时,Internet Explorer 会执行各种有趣的操作。我们仍然认为这是一个 IE 错误,但至少我们找到了解决方法。

背景信息:在初始页面生成期间,包含一些 PHP 文件,但对于连续请求不包含这些文件(因为现在大多数生成的内容都已缓存,并且不需要运行这些文件)。其中一些包含的 PHP 文件包含 UTF-8 BOM。由于 BOM 位于 PHP 开始标记之前,因此它会流式传输到 PHP 的输出。

我们通过比较 fiddler 中的输出发现了这一点,错误发生时文件大小相差 3、6 或 9 个字节。对输出运行 diff 显示了 BOM 标头,在大多数 Windows 编辑器中进行比较时没有显示它,因为这些编辑器了解 BOM。于是问题就被隐藏了。感谢IE 2.5天的无用功!

We found it: Internet Explorer does all sorts of funny things when the HTML file returned from the server contains a UTF-8 BOM. We still consider this a IE bug but at least we found a work around.

Background info: During initial page generation some PHP files where included which are not included for successive requests (because most generated content is cached now and these files do not need to be run). Some of such included PHP files included a UTF-8 BOM. Because the BOM comes before the opening PHP tag, it is streamed out to the output of PHP.

We figured it out by comparing outputs in fiddler and the file sizes differed by 3, 6 or 9 bytes when the error occured. Running a diff over the outputs showed the BOM header, comparing in most Windows editors didn't show it because these editors know about a BOM. So the problem was hidden. Thank you IE for 2.5 days of useless work!

请帮我爱他 2024-12-19 07:56:38

如果您再次遇到此类问题,请考虑使用 config.baseURL > 删除 base 标记,并使用绝对 URL 呈现所有链接:

要么使用 config .absRefPrefix = http://www.example.org/mysubfolder/(大多数保存变体)或使用config.absRefPrefix = /

If you ever run into such a problem again, consider removing the base tag with config.baseURL > and render all links with an absolute URL:

Either use config.absRefPrefix = http://www.example.org/mysubfolder/ (most save variant) or use config.absRefPrefix = /.

她比我温柔 2024-12-19 07:56:38

我怀疑您没有在标签中使用绝对路径。 IE 可以忽略您的标签,因为它没有正确指定。请参阅http://www.w3schools.com/tags/tag_base.asp

i suspect you're not using an absolute path in the tag. IE is allowed to ignore your tag since its not specified correctly. See http://www.w3schools.com/tags/tag_base.asp

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