暂时想放google analytics: 代码如下: 代码: <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-63296-3"; urchinTracker(); </script> 比如我调用的js文件为stat.js stat.js代码如下: 代码: // JavaScript Document document.write ('<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">'); document.write ('</script>'); document.write ('<script type="text/javascript">'); document.write ('_uacct = "UA-63296-3";'); document.write ('urchinTracker();'); document.write ('</script>'); 但是调用后页面会有js错误: Line:434 Char:23 Code:0 Error:缺少对象 js不懂,请问这个怎么解决?谢谢!
请教别人以后,别人叫我stat.js改成下面这样,但是问题依旧,晕倒,帮下忙吧! HTML: document.write( '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>\ <script type="text/javascript">\ _uacct = "UA-63296-3";\ (function(){\ try{\ urchinTracker();\ }catch(e){\ setTimeout(arguments.callee,500);\ }\ })();\ </script>' );
看看修改成这样 PHP: document.writeln("<script src=\"http:\/\/www.google-analytics.com\/urchin.js\" type=\"text\/javascript\">"); document.writeln("<\/script>"); document.writeln("<script type=\"text\/javascript\">"); document.writeln("_uacct = \"UA-63296-3\";"); document.writeln("urchinTracker();"); document.writeln("<\/script>");