使用html jquery ON LOAD将内容分享到什么应用程序

时间:2016-11-23 13:28:28

标签: jquery onload whatsapp

我正在开发内容共享到窗口加载事件的应用程序。但它没有重定向到url下面: " WhatsApp的://发送文本= Mytextwriteenhere- http://someurl.com"

下面是我的代码,它已经从堆栈溢出:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script><script>
$(document).ready(function () {
    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());
        }
    };
    if (isMobile.any()) {
        var text = "yyyyyyyy";
        var url = "http://google.com";
        alert(text);
        var message = encodeURIComponent(text) + " - " + encodeURIComponent(url);
        var whatsapp_url = "whatsapp://send?text=" + message;
        document.location.replace(whatsapp_url);
        // window.location.href = whatsapp_url;
    } else {
        var text = "yyyyyyyy";
        var url = "http://google.com";
        alert(text);
        alert("Please share this article in mobile device");
        window.close();
    }
});

0 个答案:

没有答案