简单两步实现自动统计网站页面访问量和访客量
- 页面引入
auto-count-pv.js
,因其依赖于jquery.js
,所以需要一并引入,若网站中已引入jquery.js
,无需重复引入
1 | <script src="//cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js" crossorigin="anonymous"></script> |
- 在页面显示访问量和访客量
1 | 访问量: <span class="auto_count_pv"></span> |
若在本地调试,页面须配置域名访问,如:http://localhost/index.html
若出现跨域报错
1
2
3
4var _script = document.createElement('script');
_script.type = "text/javascript";
_script.src = "//open.source.lee23.top/auto-count-pv/js/auto-count-pv.js";
document.head.appendChild(_script);
浏览
访客
赏
使用支付宝打赏
使用微信打赏
若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏
扫描二维码,分享此文章