I have a working whatsapp <a>
tag in this way:
<a class="whatsapp share-local-button data-action="share/whatsapp/share" target="_blank" href="whatsapp://send?text=link#withMark" > <i class="fa fa-whatsapp"></i> </a>
This works, but what is in href
is simply the shared text, not the url, which is the current....
I tried with
data-href="link#withMark"
But no different results...
How can I share my customized url and not the current one?
2 Answers
Answers 1
Try adding something like a bit of PHP if you are able to. if you want to keep it clean html then just ignore this.
in php u define the link u want to set in a variable, then just add <?php $yourvariable ?>
to the whatsapp://send?text= INSERT HERE
Answers 2
Add a JavaScript code as I did to dynamically add the link.
Also it is reusable and can be used in any page.
Here, we set the href
of the element having class=whatsapp
to it's href+
the site link.
Try running the code
document.getElementsByClassName('whatsapp')[0].href+=window.self.location;
<a class="whatsapp share-local-button data-action="share/whatsapp/share" target="_blank" href="whatsapp://send?text="> <i class="fa fa-whatsapp">whatsapp</i> </a>
0 comments:
Post a Comment