谷歌分析为 IE8 创建损坏的链接

发布于 2024-09-24 08:03:29 字数 977 浏览 3 评论 0原文

我们已经成功运行 Django 网站几年了。我们的大多数页面都使用以下(标准)谷歌分析代码。

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

在 Django 中,每次链接失效时我们都会收到一封电子邮件。最近,我们的一位用户生成了大量与谷歌分析相关的失效链接。错误消息看起来与此类似(其中 apage 是任意 url):

Referrer: http://ourwebsite.com/apage/
Requested URL: /apage/.google-analytics.com/ga.js
User agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322) IP address: 127.0.0.1

根据错误消息,我怀疑问题与 IE8 和某些安全设置或模式有关。我尝试运行 IE8 的 Utilu IE Collection 版本来重现该问题,但没有成功。

任何帮助将不胜感激。

We have been successfully running a Django site for a couple of years. We use the following (standard) google analytics code for most of our pages.

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

In Django the settings are such that we get an email every time there is a broken link. Recently, one of our users has been generating a lot of broken links that are related to google analytics. The error messages look similar to this (where apage is any url):

Referrer: http://ourwebsite.com/apage/
Requested URL: /apage/.google-analytics.com/ga.js
User agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322) IP address: 127.0.0.1

Based on the error message, I suspect the problem is related to IE8 and some security settings or modes. I have tried running the Utilu IE Collection version of IE8 to reproduce the problem, but had no luck.

Any help would be appreciated.

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

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

发布评论

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

评论(1

清晨说晚安 2024-10-01 08:03:29

我猜想存在一个运算符优先级错误/怪癖,因为它看起来

('https:' == document.location.protocol ? 'https://ssl' : 'http://www')

(在代码片段的第 8 行)可能会被解析

('https:' == (document.location.protocol ? 'https://ssl' : 'http://www'))

'https:' == 'https://ssl' 和 false

而正确的意图似乎是

(('https:' == document.location.protocol) ? 'https://ssl' : 'http://www')

当您用括号强制优先级时会发生什么(参见上一行)?

I'd guess at an operator precedence bug/quirk, as it looks that

('https:' == document.location.protocol ? 'https://ssl' : 'http://www')

(at line 8 of your snippet) may be parsed as

('https:' == (document.location.protocol ? 'https://ssl' : 'http://www'))

which would evaluate to 'https:' == 'https://ssl' and to false,

whereas the correct intent seems to be

(('https:' == document.location.protocol) ? 'https://ssl' : 'http://www')

What happens when you force the precedence with parentheses (see previous line)?

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