WhatsApp use only html to share url link by a descriptive text

Viewed 37512

I want to enable my website users to share the current web page url (stored in ViewBag.OgUrl) via WhatsApp.

The WhatsApp message should contain the url title (stored in ViewBag.OgTitle) which, when clicked, will open the url (stored in ViewBag.OgUrl).

This needs to be done by html without js.

The standard way is:

 @{
    var urlWhatsapp = "whatsapp://send?text=" + @ViewBag.OgUrl;
  }

And then simply:

 <a href="@urlWhatsapp" target="_blank">WhatsApp Share</a>

This works fine apart from the fact that the actual url is shared and not the title.

For example, a WhatsApp message contains the actual link http://example.org/ while I would like it to show in WhatsApp:

First example

Edit: If one wants to get the title and the link just replace the code with:

  @{var urlWhatsapp = "whatsapp://send?text=" + @ViewBag.OgTitle + " - " + @ViewBag.OgUrl;}

<a class="fa fa-whatsapp" href="@urlWhatsapp" target="_blank"></a>

If one waits after the sharing, but before actually sending the message to the recipient, a clickable box appears above the original message (as would be for any whatsapp link with what is defined in the url - an image, text etc. according - see the example below) enter image description here

4 Answers

Try:

<a href="https://web.whatsapp.com/send?l=en&phone=+91 0000000000&text=I want to 
order a website" target="blank"></a>

Where 0000000000 will be your 10 digit mobile no. and text= will be your predefined message.

You have two options to send messages to Whatsapp from a link on your site.

The first one...

<a href="https://wa.me/5579XXXXXXXXX"><i class="fab fa-whatsapp"></i> +55 (79) XXXXX-XXXX</a>

The second, with predefined text...

<a href="https://wa.me/5579XXXXXXXXX?text=I'm%20interested%20to%20know%20more%20about%20your%20job."><i class="fab fa-whatsapp"></i> +55 (79) XXXXX-XXXX</a>
  • You don't need to put "+" (plus) in your number.
  • To do spaces in the text, you need to use "%20" between words.
Related