一页面,种种原因导致,结构如下
<html>
<head></head>
<body>
...
<script>
document.write('统计代码');
</script>
<script>
// 页面JS代码
</script>
</body>
</html>
问题:
1.统计代码先于页面JS执行,影响页面中JS动态加载的JS文件加载。
2.统计代码内部有 document.write 一些东西到页面里。有时候会 write 操作时直接把整个已加载好的页面重写了。
求解决办法,如何让统计代码最后执行,如何防止统计代码内部 document.wirte 操作重写页面?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
javascript - JS统计代码处理-PHP中文网问答-javascript - JS统计代码处理-PHP中文网问答
围观一下哦,学习一下。
window.onload = function(){ document.write('统计代码'); }这个试过么