Sharing link on WhatsApp from mobile website (not application) for Android
The above answers are bit outdated. Although those method work, but by using below method, you can share any text to a predefined number. The below method works for android, WhatsApp web, IOS etc.
You just need to use this format:
<a href="https://api.whatsapp.com/send?phone=whatsappphonenumber&text=urlencodedtext"></a>
UPDATE-- Use this from now(Nov-2018)
<a href="https://wa.me/whatsappphonenumber/?text=urlencodedtext"></a>
Use: https://wa.me/15551234567
Don't use: https://wa.me/+001-(555)1234567
To create your own link with a pre-filled message that will automatically appear in the text field of a chat, use https://wa.me/whatsappphonenumber/?text=urlencodedtext where whatsappphonenumber is a full phone number in international format and URL-encodedtext is the URL-encoded pre-filled message.
Example:https://wa.me/15551234567?text=I'm%20interested%20in%20your%20car%20for%20sale
To create a link with just a pre-filled message, use https://wa.me/?text=urlencodedtext
Example:https://wa.me/?text=I'm%20inquiring%20about%20the%20apartment%20listing
After clicking on the link, you will be shown a list of contacts you can send your message to.
For more information, see https://www.whatsapp.com/faq/en/general/26000030
Currently, it's very easy to achieve this. You only need to add the following code to your pages:
<a href="whatsapp://send?text=<<HERE GOES THE URL ENCODED TEXT YOU WANT TO SHARE>>" data-action="share/whatsapp/share">Share via Whatsapp</a>
And that's it. No Javascript needed, nothing else needed. Of course you can style it as you want and include a nice Whatsapp icon.
I tested this in my Android device with Google Chrome. The versions:
- Android 4.1.2 (Jelly Bean)
- Chrome Mobile 37.0.2062.117. Also tested on Firefox Mobile 31.0.
- Whatsapp V 2.11.399
It also works on iOS. I've made a quick test on an iPhone 5 with Safari and it works as well.
Hope this helps someone. :-)
Just saw it on a website and seems to work on latest Android with latest chrome and whatsapp now too! Give the link a new shot!
<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>
Rechecked it today (17th April 2015):
Works for me on iOS 8 (iPhone 6, latest versions) Android 5 (Nexus 5, latest versions).
It also works on Windows Phone.