首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Javascript代码片段冻结Firefox3.6

Javascript代码片段冻结Firefox3.6
EN

Stack Overflow用户
提问于 2011-12-08 08:38:37
回答 1查看 291关注 0票数 4

这段代码冻结了Firefox 3.6。

代码语言:javascript
复制
 // 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?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-10 19:43:10

这显然与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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8424721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档