我想在网页上放置一个链接,以打开与某个whatsapp联系人的聊天。换句话说:我想要一个“通过whatsapp联系我”的链接,放在页面的“通过Facebook / Twitter / Google+ /等”链接旁边。类似于:
href="whatsapp:contact=015555555555@s.whatsapp.com&message="I'd like to chat with you"
我想在网页上放置一个链接,以打开与某个whatsapp联系人的聊天。换句话说:我想要一个“通过whatsapp联系我”的链接,放在页面的“通过Facebook / Twitter / Google+ /等”链接旁边。类似于:
href="whatsapp:contact=015555555555@s.whatsapp.com&message="I'd like to chat with you"
这篇答案适用于那些希望在网站中通过点击聊天Whatsapp的人,将其重定向到web.whatsapp.com并使用默认内容或消息,在移动设备上以默认内容打开Whatsapp移动应用程序并输入文本栏的人。
还需添加jQuery链接。
<a target="_blank" title="Contact Us On WhatsApp" href="https://web.whatsapp.com/send?phone=+919581880892&text=Hi, I would like to get more information.." class="whatsapplink hidemobile" style="background-color:#2DC100">
<i class="fa fa-fw fa-whatsapp" style="color:#fff"></i>
<span style="color:#fff">
Contact Us On WhatsApp </span>
</a>
<a target="_blank" title="Contact Us On WhatsApp" href="https://api.whatsapp.com/send?phone=+919581880892&text=Hi,%20I%20would%20like%20to%20get%20more%20information.." class="whatsapplink hideweb" style="background-color:#2DC100">
<i class="fa fa-fw fa-whatsapp" style="color:#fff"></i>
<span style="color:#fff">
Contact Us On WhatsApp </span>
</a>
<script type="text/javascript">
var mobile = (/iphone|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
$('.hidemobile').css('display', 'none'); // OR you can use $('.hidemobile').hide();
}
else
{
$('.hideweb').css('display', 'none'); // OR you can use $('.hideweb').hide();
}
</script>
https://wa.me/PHONENUMBERHERE
了。 - Avatar我在网页上尝试了所有的瑞士号码组合。以下是我的结果:
Android和iOS不兼容
https://wa.me/0790000000/?text=myText
适用于iOS但不适用于Android
https://wa.me/0041790000000/?text=myText
https://wa.me/+41790000000/?text=myText
适用于Android和iOS:
https://wa.me/41790000000/?text=myText
https://wa.me/041790000000/?text=myText
对我有效的解决方案在这里,使用PHP
实现:
$android = stripos($_SERVER['HTTP_USER_AGENT'], "android");
$iphone = stripos($_SERVER['HTTP_USER_AGENT'], "iphone");
$ipad = stripos($_SERVER['HTTP_USER_AGENT'], "ipad");
$whatsappNumber = '1234597891';
$whatsappLink = '';
if($android !== false || $ipad !== false || $iphone !== false) {//For mobile
$whatsappLink = '<a href="https://api.whatsapp.com/send?phone='.$whatsappNumber.'">'.$whatsappNumber.'</a>';
} else {//For desktop
$whatsappLink = '<a href="https://web.whatsapp.com/send?phone='.$whatsappNumber.'">'.$whatsappNumber.'</a>';
}
<a href="https://api.whatsapp.com/send?phone=19998887878&text=Hi%20There!">WhatsApp Now</a>