我想知道是否可以在桌面网站上添加WhatsApp分享按钮并使用WhatsApp Web共享数据。移动插件可用,但桌面版我找不到任何内容。有人可以建议一些东西吗。
我尝试了一些代码,其中链接正在打开,但如何附加数据?
这是JavaScript:
<script type="text/javascript">
$(document).ready(function() {
$('.whatsapp').on("click", function(e) {
if(/Android|webOS|iPhone|iPad|iPod|Chrome|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
var article = $(this).attr("data-text");
var weburl = $(this).attr("data-link");
var whats_app_message = encodeURIComponent(article)+" - "+encodeURIComponent(weburl);
var whatsapp_url = "https://web.whatsapp.com://send?text="+whats_app_message;
window.location.href= whatsapp_url;
}else{
alert('you are not using mobile device.');
}
});
});
</script>
这里是HTML代码
<div class='web'>
<h2><a href='http://www.stepblogging.com/google-cloud-messaging-push-notification-in-android-using-php-mysql/' target='_blank'>Google Cloud Messaging / PUSH Notification in Android using PHP, MYSQL</a></h2>
<p>Google Cloud Messaging for Android (GCM) is a free service that helps us to send data from your server to their Andriod application on Andriod devices.</p>
<a data-text="Google Cloud Messaging / PUSH Notification in Android using PHP, MYSQL" data-link="http://www.stepblogging.com/google-cloud-messaging-push-notification-in-android-using-php-mysql/" class="whatsapp">Share</a>
<h2><a href='http://www.stepblogging.com/php-login-script-using-pdo/' target='_blank'>PHP Login Script using PDO</a></h2>
<p>Are you looking for basic PHP login script. In this tutorial I want to discuss how to create a login page using PHP/MySQL with PDO Query , welcome and logout page. If you are a PHP beginner take a quick look at this live demo with Username : demo Password :demo. </p>
<a data-text="PHP Login Script using PDO" data-link="http://www.stepblogging.com/php-login-script-using-pdo/" class="whatsapp">Share</a>
</div>