I am trying to record the number of clicks performed by the user on the hyperlinks that are being retrieved from the Database on the web page.
This is my code:
echo "Name: ". $row["user"] . str_repeat(' ', 5).
'<a href="'.$row['lin'].' onClick= "Click();" ">Click</a>';
below is the function being called:
function Click() {
if (typeof(Storage) !== "undefined") {
if (localStorage.clickcount) {
localStorage.clickcount = Number(localStorage.clickcount)+1;
} else {
localStorage.clickcount = 1;
}
document.getElementById("result").innerHTML = "You have clicked " + localStorage.clickcount + " time(s).";
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
}
return true;
}
Above is not showing the count when clicking on the hyperlinks. Any idea?
Aucun commentaire:
Enregistrer un commentaire