Reputation: 389
I have a blog app build on rails, i was searching on how to add a share button for WhatsApp, so that users can share the article they are reading with there contacts, i got something that worked in this answer.
According to the answer:
<a href="whatsapp://send?text=SHAREMESSAGE">Share on WhatsApp</a>
This worked but i want to share current URL when a user click the button.
Upvotes: 1
Views: 3974
Reputation: 945
You can use basic DOM concept with JS to get the current URL, like:
var x = document.URL
window.location.href = "whatsapp://send?text="+x
Upvotes: 4
Reputation: 33460
Use the Request#original_url
:
<a href="whatsapp://send?text=<%= request.original_url %>">Share on WhatsApp</a>
Upvotes: 5