Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

326
Visualizações
CountAPI, how to register clicks from middle mouse button and the left one

This script doesn't work with the middle mouse button, only count the clicks from the left button. I want to add functionality to work with the middle one too, but how? and suggestions?

  <body>
    <a href="https://www.google.com" target="_blank" onclick="countClick('google1')">Google</a>
    <a href="https://www.duckduckgo.com" target="_blank" onclick="countClick('duckduckgo1')">DuckDuckGo</a>

    <div>Google was clicked <span id="google1_clicks">0</span> times.</div>
    <div>DuckDuckGo was clicked <span id="duckduckgo1_clicks">0</span> times.</div>
    
    <script>
      const requestHandler = async function(type, key) {
        return await fetch(`https://api.countapi.xyz/${type}/test/${key}`)
        .then(res => res.json())
        .then(res => res.value || 0)
        .catch(() => 0)
      }

      const loadClicks = (async function() {
        document.getElementById('google1_clicks').innerHTML = await requestHandler('get', 'google1')
        document.getElementById('duckduckgo1_clicks').innerHTML = await requestHandler('get', 'duckduckgo1')
      })()

      const countClick = async function(key) {
        document.getElementById(`${key}_clicks`).innerHTML = await requestHandler('hit', key)
      }
    </script>
  </body>
</html>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda