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

194
Visualizações
How to show an error message if viber sharing is not available?

Say, I'm on desktop, or on Android which has no Viber application. I press it and nothing happens. A notice message ought to be shown, like "Install the Viber application!" or something like that. All I have is this:

<a href="viber://forward?text=text">Click here to share!</a>

I tried these:

<a href="whatsapp://send/?phone=62812345678&amp;text=test" id="openWA">Send to WhatsApp</a>
<br>
<a href="viber://forward?text=paff" id="openV">Send to Viber</a>

<!-- Auto open on WebView and Firefox -->

<script>
    document.querySelector('#openWA').addEventListener('click', function() {
        var f = Date.now(),
            j = setTimeout(function() {
                if (Date.now() - f > 1250)
                    return;
                alert('WA not installed')
            }, 1e3);
    });
    document.querySelector('#openV').addEventListener('click', function() {
        var f = Date.now(),
            j = setTimeout(function() {
                if (Date.now() - f > 1250)
                    return;
                alert('VIBER not installed')
            }, 1e3);
    });
</script>

but it say "not installed", either it is or not.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try using this

  <a href="#" id="openWA">Send to WhatsApp</a>
<br>
<a href="#" id="openV">Send to Viber</a>

<!-- Auto open on WebView and Firefox -->

<script>
    document.querySelector('#openWA').addEventListener('click', function() {
      setTimeout(() =>{
        alert("Whatsapp not installed")
      }, 500)
      window.location.replace('whatsapp://send/?phone=62812345678&amp;text=test')
            
    });
    document.querySelector('#openV').addEventListener('click', function() {
      setTimeout(() =>{
        alert("Viber not installed")
      }, 500)
      window.location.replace('viber://forward?text=paff')
            
    });
</script>

For more information see this stackoverflow post How to check app is installed or not using javascript

about 4 years ago · Juan Pablo Isaza Relatório
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