web喚起whatsapp客戶端通過號碼聯系


如果安裝了whatsapp客戶端,只需跳轉

window.location.href = "https://wa.me/號碼";

如果有區號則只需在前面直接加區號,例如加香港區號:

https://wa.me/852XXXXXXXX
if (window.navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
       window.location.href = "https://wa.me/號碼";
       setTimeout(function () {
            window.location.href = "https://itunes.apple.com/us/app/whatsapp-messenger/id310633997?mt=8";
            window.location.href = "https://itunes.apple.com/us/app/whatsapp-messenger/id310633997?mt=8";
        }, 2000);
    } else if (window.navigator.userAgent.match(/android/i)) {
        window.location.href = "https://wa.me/號碼";;
        setTimeout(function () {
            window.location.href = "https://play.google.com/store/apps/details?id=com.whatsapp";
        }, 2000)
    }

或者可以到 http://www.conversabit.com/wasap.js/ 提供的小插件自動適配

html:
<span data-whatsapp="5215585420898">This will be clickable on mobile</span>
javascript:
wasap.init()

插件還能配合vue應用,具體查看官網


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM