Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom URL scheme to open text in whatsapp from mobile browser, newline / line break not working

I am using the following code: (jquery)

window.open("whatsapp://send?text=Hello World!")

To open and share a message from the mobile browser, this documentation can be found here: https://www.whatsapp.com/faq/android/28000012

However, I'd like to add a 'newline' somewhere in the message.

I tried: \n <br> <br/> &lt;br&gt; in the message but these do not seem to work properly.

\n \r only give me a "space" as well as +

&lt;br&gt; breaks the sentence off.

Anyone that can give me some insight into how I generate a linebreak in the whatsapp message from a (mobile) browser?

Really stuck here!

like image 709
Snowlav Avatar asked May 02 '15 16:05

Snowlav


People also ask

How do I add a line break in WhatsApp link?

How to add a line break: I have tried \n , \r\n , PHP_EOL , and %0D%0A , but it just displays as text. Try to use: PHP_EOL instead of \n .

How do you use wa me?

Use https://wa.me/<number> where the <number> is a full phone number in international format. Omit any zeroes, brackets, or dashes when adding the phone number in international format.


1 Answers

Based on the URL scheme I'm pretty sure that %0A is the way to go, you could go as far as %0A%0D...

window.open("whatsapp://send?text=Hello%20World!%0AAnother%20Word")

Most languages will have a method for URL encoding - see this website for an example implementation:

http://meyerweb.com/eric/tools/dencoder/

like image 88
user230910 Avatar answered Oct 19 '22 22:10

user230910