【问题标题】:HTML Button Clicker Counter Unique ClickHTML 按钮点击器计数器唯一点击
【发布时间】:2016-10-07 11:24:15
【问题描述】:

我正在为按钮点击计数器搜索一个简单的 html 代码,我发现了这个site

但是,我需要点击是反垃圾邮件,所以我只需要一个按钮,每个 IP 地址只允许点击一次。

帮助?

代码如下:

    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>

【问题讨论】:

    标签: button click unique counter


    【解决方案1】:

    Here 是一个发布了一长串不同的免费 ip 查找服务的人,这些服务都返回请求者的 JSON 对象。根据您的后端,您可以使用此信息并存储已单击该按钮的 IP 地址。这种方式也更安全,因为 localStorage 将数据存储在用户浏览器中,他们可以清除该数据并再次单击。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-14
      相关资源
      最近更新 更多