I need a code that will help a website visitor (on Wordpress) to make mobile calls or to activate WhatsApp when clicking a particular button.
Any tips?
I need a code that will help a website visitor (on Wordpress) to make mobile calls or to activate WhatsApp when clicking a particular button.
Any tips?
You can use the URL scheme whatsapp://
in the href
attribute of a hyperlink followed by the message that will be shared. For example:
<a href='whatsapp://send?text=testando 1 2 3'>Compartilhar "testando 123"</a>
If the user has the application installed, it will be initialized allowing a contact to be chosen next to a text field that allows editing the message before sending.
Because the browser is still not able to access WhatsApp the way it is done on mobile devices - this URL scheme is unknown - it may be interesting to hide that link and display it only on smaller screens:
/**
* Tamanho somente para ilustrar! Tenha em mente que
* a instalação do aplicativo não é restrita a smartphones.
*/
@media screen and (max-device-width: 860px)
.compartilhar-whatsapp {
display: block
}
}
Some links in frequently asked questions about the application that cites the use of this custom url schema:
You can use tel: 000000000 . Ex:
<a href="tel:21912345678">ligar agora</a>