• home > webfront > ECMAS > javascript >

    chrom报错:Failed to execute 'write' on 'Document': It isn't possibl

    Author:zhoulujun Date:

    异步加载js代码,如果使用Document write会报错Failed to execute ……解决办法与原因分析

    今天添加第三方统计代码,发现,浏览器报错:

    Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened. 

    并没有达到如期效果。

    百思不得骑姐啊。

    对比下官方代码,我加了 defer='defer' 或者 async='async',

    不想让js阻塞主流程。就是这点点差别,就出现如此情况。

    把异步加载,取消,发现,可以了。

    其实,看提示结果,也可以看出啊。

    It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened



    转载本站文章《chrom报错:Failed to execute 'write' on 'Document': It isn't possibl》,
    请注明出处:https://www.zhoulujun.cn/html/webfront/ECMAScript/js/2015_0806_8103.html