繁体   English   中英

Javascript片段冻结了Firefox3.6

[英]Javascript snippet freezes Firefox3.6

这段代码冻结了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代码中的插入代码段,该代码片段完美无瑕。

所以问题是,为什么它会冻结Firefox 3.6以及当运行非常相似的代码加载Google Analytics脚本ga.js时它为什么不冻结Firefox3.6?

这显然与conversion.js中的document.write()有关。

http://jsfiddle.net/LLSu4/19/

ga.js不使用document.write ,因此没有问题。

在插入的脚本中使用document.write绝不是一个好主意。 这会混淆HTML引擎。 你会发现bugzilla有几个关于appendChilddocument.write bug,比如https://bugzilla.mozilla.org/show_bug.cgi?id=607222

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM