I try to make a view counter in js for my webpage.
When you view the page, the counter will increase with 1.
The counted numbers are displayed.
But one thing is not working: When I view the website from another device, the counter starts at 0.
So I used localStorage to store the data. But I want when I see the page from my laptop, the counter increases by one. And when I view the page from my phone the counter should already show the number one and should increase it with one ,so the counter will be 2.
I don't know how to make it workable. It's only done with LocalStorage. I thought I should save the data, by storing the data in a .txt file, but it does not work because when the filewriter save the datas (1) into the file, it will save the next view (1) next to the previous number. And if I want to add the current number to the previous it will show number 1.
Here's my code:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…