这段代码冻结了Firefox 3.6。
// Google Code for Converted Users Remarketing List
function converted_remarketing() {
window.google_conversion_id = 1018522404;
window.google_conversion_language = 'en';
window.google_conversion_format = '3';
window.google_conversion_color = '666666';
window.google_conversion_label = 'e9x2CKzhXXXXpNbV5QM';
window.google_conversion_value = 0;
var a = document.createElement('script');
a.type = 'text/javascript';
a.async = true;
a.src = 'https://www.googleadservices.com/pagead/conversion.js';
var b = document.getElementsByTagName('script')[0];
b.parentNode.insertBefore(a, b);
}
converted_remarketing();示例页面:http://jsfiddle.net/LLSu4/11/show/
看起来像是和脚本插入有关。有趣的是,我复制了Google Analytics代码中的插入片段,它可以完美地工作。
所以问题是,为什么它冻结Firefox3.6,为什么当一个非常相似的代码加载谷歌分析脚本ga.js时,它没有冻结Firefox3.6?
发布于 2011-12-10 19:43:10
这显然与conversion.js中的document.write()有关。
请参阅http://jsfiddle.net/LLSu4/19/
ga.js不使用document.write,因此没有问题。
在插入的脚本中使用document.write从来都不是一个好主意。这会混淆HTML引擎。你会发现bugzilla有几个关于appendChild和document.write的bug,比如https://bugzilla.mozilla.org/show_bug.cgi?id=607222
https://stackoverflow.com/questions/8424721
复制相似问题