0

I was searching for a simple html code for button clicker counter and I found this site

However, I need the clicks to be anti-spam so I just need a button that allows only one click per IP address.

Help?

Here's the code:

    function clickCounter() {
        if(typeof(Storage) !== "undefined") {
            if (localStorage.clickcount) {
                localStorage.clickcount = Number(localStorage.clickcount)+1;
            } else {
                localStorage.clickcount = 1;
            }
            document.getElementById("result").innerHTML = "" + localStorage.clickcount + " people are going!";
        } else {
            document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
        }
    }
    <body>
    <p><button onclick="clickCounter()" type="button">I'M GOING!</button></p>
    <div id="result"></div>
Arkej
  • 2,221
  • 1
  • 14
  • 21

1 Answers1

0

Here is a guy who posted a long list of different free ip lookup services which all return JSON objects of the requester. Depending on your back-end you can use this information and store which ip addresses have already clicked the button. This way is also more secure since localStorage stores the data in the users browser, they could just clear that data and click again.

Community
  • 1
  • 1
Ozgar
  • 305
  • 2
  • 14