Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 618
user6099216 Avatar asked Oct 18 '22 07:10

user6099216


1 Answers

It is not possible to share a link on WhatsApp the way you want to. You can only send a message with the full link like http://example.org/ and WhatsApp will detect this as a link for you.

like image 123
Gabriel Krenn Avatar answered Oct 21 '22 07:10

Gabriel Krenn