将链接重定向到Playstore

时间:2018-12-07 04:50:54

标签: redirect vanity mobile-app-tracker

我有个虚荣链接。如果它已安装在移动设备中,则定向到移动应用程序。 否则,它将重定向到Play商店应用以安装该应用。但会打开浏览器本身,而不是打开play store应用。

$(window).load(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(/Windows Phone/i);
        },
        any: function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
        }
    };

if(isMobile.iOS())
{
    window.top.location.href="https://itunes.apple.com/id/app/citi-mobile-indonesia/id533078484?mt=8";
}
else if(isMobile.Android())
{
    window.top.location.href="https://play.google.com/store/apps/details?id=com.mobile.co.id";
}

});

0 个答案:

没有答案