0

I am working on content sharing to what's app on window load event. But it is not redirecting to below url: "whatsapp://send?text=Mytextwriteenhere-http://someurl.com"

Below is my code which is already taken from stack over flow:

<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();
    }
});

Mohit
  • 13
  • 1
  • 4

0 Answers0