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.
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.
If you want to send an only text containing newline
use this %0a
link =`whatsapp://send?text=%0aHello%0aWorld`;
If you want to send some url link with text containing newline
var encodedURL = encodeURIComponent(some_url);
link =`whatsapp://send?text=${encodedURL}%0aHello%0aWorld`;
Now embedded this link in anchor tag
<a href=link> Click here! </a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With