Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用访问计数时似乎有问题 #53

Closed
youthriverside opened this issue Jul 24, 2020 · 1 comment
Closed

使用访问计数时似乎有问题 #53

youthriverside opened this issue Jul 24, 2020 · 1 comment

Comments

@youthriverside
Copy link

image
如图,我使用如下代码进行访问统计

<script type="text/javascript""> 
if(localStorage.pagecount){localStorage.pagecount=Number(localStorage.pagecount)+1}else{localStorage.pagecount=1}document.write("欢迎你第"+localStorage.pagecount+"次访问"); 
</script>

但是每次进入文章都会像图一样

@solstice23
Copy link
Owner

有 pjax,页面没有刷新,上一次 document.write 文档流还没关闭,所以会重复

不推荐 document.write 直接写文档流,弄个 div 显示不香吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants