前端设计>JS>正文
网站对于功能性代码,如CNZZ这种代码,假设你有50个站点,实际只需要调用一个js就可以分别对50个站点独立监控,以免写很多个js,这样也便于操作。如创建一个公共js:cnzz.js。代码内容为:
thisURL = document.URL; var sign_url =null; document.write('<span style="display:none">'); //www.weguiding.com 的统计代 if(thisURL.indexOf('www.weguiding.com')>0) { var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1271191319'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s19.cnzz.com/z_stat.php%3Fid%3D1271191319' type='text/javascript'%3E%3C/script%3E"));} //m.weguiding.com 的统计代码 if(thisURL.indexOf('m.weguiding.com')>0) { var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1261060817'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1261060817' type='text/javascript'%3E%3C/script%3E")); } document.writeln('</span>');
核心技巧为:通过js判断当前域名,然后自动调用当前域名的cnzz对代码。
if花括号中填写以下图示中脚本标签中包含的内容即可
多站点的添加直接复制下图中的机构体,修改对应的域名和cnzz代码即可
本文链接:https://www.weguiding.com/js/418.html
- 上一篇:网页中图片自动按比例缩放
- 下一篇:JS动态插入内容到网页
猜你喜欢
- 20-01-08 JS动态插入内容到网页
- 19-05-04 站群或者多个网站判断调用CNZZ代码
- 19-05-04 网页中图片自动按比例缩放
- 05-04网页中图片自动按比例缩放
- 01-08JS动态插入内容到网页
- 05-04站群或者多个网站判断调用CNZZ代码
- 05-04网页中图片自动按比例缩放
- 05-04站群或者多个网站判断调用CNZZ代码
- 05-04网页中图片自动按比例缩放
- 图文推荐