Snowlav
Snowlav

Reputation: 465

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!

Upvotes: 9

Views: 18958

Answers (1)

user230910
user230910

Reputation: 2372

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/

Upvotes: 26

Related Questions