rav*_*tel 7 html php jquery whatsapp
我一直在使用WhatsApp共享消息:
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>
Run Code Online (Sandbox Code Playgroud)
如何添加换行符:
我已经试过\n,\r\n,PHP_EOL,和%0D%0A,但它只是显示为文本.
小智 33
如果您只想发送包含换行符的文本
use this %0a
link =`whatsapp://send?text=%0a?Hello%0aWorld`;
Run Code Online (Sandbox Code Playgroud)
如果你想发送一些包含换行符的 url 链接
var encodedURL = encodeURIComponent(some_url);
link =`whatsapp://send?text=${encodedURL}%0a?Hello%0aWorld`;
Run Code Online (Sandbox Code Playgroud)
现在将此链接嵌入到锚标记中
<a href=link> Click here! </a>
Run Code Online (Sandbox Code Playgroud)
小智 10
要在 WhatsApp 中创建换行符,您可以使用此命令。它工作正常,我正在使用它:
use `%0a`
Run Code Online (Sandbox Code Playgroud)
例如:
smsContain = "*Greetings from " + cname + " ,%0a %0aM/s. " + txtName.Text + " %0a %0aYour Bill for Advertisement is generated ; %0a %0aBill Date :- " + DateTime.ParseExact(dateTimePicker1.Text, "dd/MM/yyyy", null).ToString("dd/MM/yyyy") + " %0a %0aBill no :- " + lblBillNo.Text + " %0a %0aBilling Amount of Rs. " + lblNet_Amt.Text + " %0a %0aAdvertisement Published in " + news + " in " + Edi + " edition,%0a %0aReleased Date : " + DateTime.ParseExact(DateTime.Parse(dt).ToShortDateString(), "dd/MM/yyyy", null).ToString("dd/MM/yyyy") + ".%0a %0aPlease find the Bill attached below, and request you to please release the payment ASAP. %0a %0a %0aAny descripancy in regards to this Bill to reported to us immediately.%0a %0a %0aAlways at your Service....* ";
smsContain = smsContain.Replace("&", "+%26+");
Run Code Online (Sandbox Code Playgroud)
我得到了一个可行的解决方案:
HTML:
$_u.="Product Name:".$_productName."\n";
$_u.="Sku:".$_productSku."\n";
<a data-text="<?php echo $_u; ?>" data-link="" class="whatsapp">Share</a>
Run Code Online (Sandbox Code Playgroud)
JS:
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
$(document).on("click", '.whatsapp', function() {
if( isMobile.any() ) {
var text = $(this).attr("data-text");
var url = $(this).attr("data-link");
var message = encodeURIComponent(text) + " - " + encodeURIComponent(url);
var whatsapp_url = "whatsapp://send?text=" + message;
window.location.href = whatsapp_url;
} else {
alert("Please share this in mobile device");
}
});
Run Code Online (Sandbox Code Playgroud)