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

15,750

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/

Share:
15,750
Snowlav
Author by

Snowlav

Updated on July 23, 2022

Comments

  • Snowlav
    Snowlav almost 2 years

    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!