Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create line break in WhatsApp message

Tags:

I have been working on WhatsApp sharing message using:

whatsapp-button.js

$_u.="Product Name:".$_productName."\n";

$_u.="Sku:".$_productSku."\n";

<a href="whatsapp://send" data-text="<?php echo nl2br($_u); ?>" data-href="" class="wa_btn <?php echo $buttonsize; ?>" style="display:none">Share</a>

How to add a line break:

I have tried \n, \r\n, PHP_EOL, and %0D%0A, but it just displays as text.

like image 595
Ravi Patel Avatar asked Jan 05 '15 13:01

Ravi Patel


People also ask

How do you skip a line on WhatsApp iPhone?

In order to add a line break, simply bring up the iOS keyboard, hold down the 'Shift' key and then press the 'Return' key at the same time.


1 Answers

If you want to send an only text containing newline

use this %0a


link =`whatsapp://send?text=%0a‎Hello%0aWorld`;

If you want to send some url link with text containing newline

var encodedURL = encodeURIComponent(some_url);
link =`whatsapp://send?text=${encodedURL}%0a‎Hello%0aWorld`;

Now embedded this link in anchor tag

<a href=link> Click here! </a>
like image 135
am2505 Avatar answered Sep 28 '22 02:09

am2505