chrome报错a parser-blocking, cross-origin script, is invoked via document.write.
时间:08-18来源:作者:点击数:
确切的说是警告,内容是:
A Parser-blocking, cross-origin script, http://s4.cnzz.com/stat.php?id=xxx&show=pic, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.
错误原因是:页面渲染完成后使用了document.write()(cnzz统计代码引起的,chrome53以上版本会报错。)。
解决方案:将统计代码改为异步加载
var cnzz_s_tag = document.createElement('script');
cnzz_s_tag.type = 'text/javascript';
cnzz_s_tag.async = true;
cnzz_s_tag.charset = 'utf-8';
cnzz_s_tag.src = 'https://w.cnzz.com/c.php?id=xxxxxx&async=1';
var root_s = document.getElementsByTagName('script')[0];
root_s.parentNode.insertBefore(cnzz_s_tag, root_s); |