There is a page with a "share at whatsapp" button. This creates and executes an URL like:
whatsapp://send?text=Some text followed by a link - http://link_to_this_page#something
The problem is that the browser (I've tested only with Chrome for now) automatically deletes from the hash sign to onwards.
I have tried the basic:
var href = 'whatsapp://send?text=Example text - ';
var uri = location.protocol + '//' + location.host + location.pathname + '#gm.';
location.href = href + uri;
I tried too with location.replace(), location.assign() and window.open() with no luck.
So the question is, how can I do? It's imperative to use the hash because it tells to the target page that it has to do some things in javascript (which could take more time to change).
You should be encoding anything that is in the query string.
location.href = href + encodeURIComponent(uri);
You probably should be doing:
var href = 'whatsapp://send?text=';
var text = 'Example text - ';
var uri = location.protocol + '//' + location.host + location.pathname + '#gm.';
location.href = href + encodeURIComponent(text + uri);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With