Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<html>
<head>
<script type="text/javascript">
<!--
var fsObj = null; // holds a pointer to the FileSystemObject
var counter = 0; // holds the counter value
var counterFile = 'C:\\jsCounter.txt'; // holds the path and filename to the counter text file
// returns 0 if no counter or NaN is found, the counter value otherwise
function readCounter() {
try {
if (!fsObj.FileExists(counterFile)) return(0);
var tempValue = fsObj.OpenTextFile(counterFile, 1).ReadLine();
if (isNaN(tempValue) || tempValue == ' || tempValue == null) return(0);
return(tempValue);
}
catch (err) {
return(0);
}
}
// returns false if write failed, true otherwise
function writeCounter(counterValue) {
try {
//alert(counterValue);
var counterFileObj = fsObj.OpenTextFile(counterFile, 2, true);
counterFileObj.WriteLine(counterValue);
counterFileObj.Close();
return(true);
}
catch (err) {
return(false);
}
}
function init() {
try {
this.fsObj = new ActiveXObject('Scripting.FileSystemObject');
}
catch (err) { }
if (!this.fsObj) {
alert('You must allow the ActiveX object to load for the counter to work');
} else {
counter = readCounter();
alert('Current counter: ' + counter);
counter++;
if (!writeCounter(counter)) alert('There was an error writing the counter');
}
}
//-->
</script>
</head>
<body onload="init();">
</body>
</html>