简体   繁体   中英

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!

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM