Js statistics processing

117 0

A page, which causes the structure to be as follows

<html>
 <head></head>
 <body>
. . .
 <script>
 document.write('统计代码');
 </script>
 <script>
//页面JS代码
 </script>
 </body>
 </html>

Problem:
1. Statistics code prior to page js execution, affecting page js dynamically loaded js file loading.
2. There are some document.write stuff inside the statistics code to the page. Sometimes write operations are written directly to the entire loaded page when writing operations.

Finding a solution, how to make statistics the final execution of the code, how to prevent the statistics from internal document.wirte operations rewriting pages?

1 Answers

88 1
window.onload = function(){
 document.write('统计代码');
}

I tried this.

...