谷歌分析为 IE8 创建损坏的链接
我们已经成功运行 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜想存在一个运算符优先级错误/怪癖,因为它看起来
(在代码片段的第 8 行)可能会被解析
为
'https:' == 'https://ssl' 和
false
,而正确的意图似乎是
当您用括号强制优先级时会发生什么(参见上一行)?
I'd guess at an operator precedence bug/quirk, as it looks that
(at line 8 of your snippet) may be parsed as
which would evaluate to
'https:' == 'https://ssl'
and tofalse
,whereas the correct intent seems to be
What happens when you force the precedence with parentheses (see previous line)?