简体   繁体   English

如何在我的网站上列出访问,以免它们再次发生?

[英]How can I list visits on my site so they don't recur?

I wanted to list all the real accesses to my web page but if I already accessed it from that device then it won't count *I can use the hosting for example the cpanel that gives me this data but I need it to print on my screen new visits *我想列出对我的网页的所有实际访问,但如果我已经从该设备访问它,那么它不会计算*我可以使用主机,例如为我提供这些数据的 cpanel,但我需要它打印在我的筛选新访问 *

below is my code:下面是我的代码:

var counterContainer = document.querySelector(".website-counter");
var resetButton = document.querySelector("#reset");
var visitCount = localStorage.getItem("page_view");

// Check if page_view entry is present
if (visitCount) {
  visitCount = Number(visitCount) + 1;
  localStorage.setItem("page_view", visitCount);
} else {
  visitCount = 1;
  localStorage.setItem("page_view", 1);
}
counterContainer.innerHTML = visitCount;

// Adding onClick event listener
resetButton.addEventListener("click", () => {
  visitCount = 1;
  localStorage.setItem("page_view", 1);
  counterContainer.innerHTML = visitCount;
});

尝试使用 cookie 而不是本地存储。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何分隔嵌套函数,以免彼此干扰? - How can I separate my nested functions so they don't interfere with eachother? 如何确保只有从特定功能重定向的用户才能访问我的网站页面? - How can I make sure that a user visits a page of my site only if he's redirected from a specific function? Javascript-如何检测弹出窗口何时访问我的网站? - Javascript - How do I detect when my popup window visits my site? 对于使用推荐链接访问我的网站的用户。 我可以捕获访问者的来源/媒体吗? - For a user that visits my site using referral link. Can I capture the source/medium of the visitor? 我正在将我的 JSX 站点迁移到 TSX,但不明白如何放置我的类型定义 - I'm migrating my JSX site to TSX and don't understand how to place my type definitions 所以我试图在一个数组中获取我的 axios 响应,但我不知道该怎么做 - So i'm trying to get my axios response in an array and I don't know how to do it 无法弄清楚为什么我的网站加载如此缓慢 - Can't figure out why my site loads so slow 如何设置滑块的上盖,以使我的下一个和上一个按钮不会滚动到空白内容之外? - How do I cap the slider so that my next and prev buttons don't scroll past the content into whitespace? 如何使用 Javascript “选择”链接,以便输入访问它 - How do I “select” a link using Javascript so enter visits it 我该如何创建一个共享或赞按钮,以便网站所有者可以将其放在自己的网站上,然后发布回我的网站? - How can I create a share or like button so that site owners can put it on their sites which will post back to my site?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM