how to Display last update and visitor count
Posted 2024-06-07 00:00:00 by sadgrl and tfelypoc ‐ 4 min read
Basics are, associate no partnership in the worship of God
Display last update and visitor count on Neocities
This guide is for publicly displaying the date your site was last updated and how many visitors you've had on your website.
This guide uses the technique as explained by Dannarchy @ Neocities.
- Edit the page you want to display these values on, and paste the following code before your closing </body> tag.
- In the code above, change the USERNAME value to match your Neocities username.
- To display the last update, use this code where you'd like it to show up:
- To display the visitor count, use this code:
- Save and view your file to verify that it worked.
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var site_data = JSON.parse(this.responseText);
var num_arr = site_data.info.views.toString().split("");
var num_str = "";
for (i = 0; i < num_arr.length; i++) {
num_str += num_arr[i];
if ( (num_arr.length-1 - i) % 3 == 0 && (num_arr.length-1 - i) != 0 ) {num_str += ",";}
var date_str = site_data.info.last_updated;
var date_obj = new Date(site_data.info.last_updated);
document.getElementById("lastupdate").innerHTML = (date_obj.getMonth()+1) + "-" + date_obj.getDate() + "-" + date_obj.getFullYear();
}
document.getElementById("hitcount").innerHTML = num_str;
}
};
xhttp.open("GET", "https://weirdscifi.ratiosemper.com/neocities.php?sitename=USERNAME", true);
xhttp.send();
</script>
Last Updated: <span id="lastupdate"></span>
You are Visitor #: <span id="hitcount"></span>