This guide is for publicly displaying a date your site was last updated and how many visitors you’ve had on your website.
It uses the technique as explained by Dannarchy here.
I just wanted to simplify it a bit and make it a little easier to implement if you’re not at a place where you can understand everything right away.
- Go to the page you want to display this information and paste the following code:
<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>
Code language: JavaScript (javascript)
- In the code above, change USERNAME to match your Neocities username.
- Wherever you want to display the last update data, use this:
Last Updated: <span id="lastupdate"></span>
Code language: HTML, XML (xml)
- Wherever you want to display your hit count, use this:
You are Visitor #: <span id="hitcount"></span>
Code language: HTML, XML (xml)
That’s all you need to do! If you’d like to learn more about how this works, definitely check out Dannarchy’s page.
wow! thanks so much!