重定向到appstore或谷歌播放 [英] redirect to appstore or google play

查看:103
本文介绍了重定向到appstore或谷歌播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会以下列格式向我的客户发送应用程序的链接:

http://goo.gl.com/downloadtheapp (或其他)



我希望这个文件位于我的服务器上,它包括java脚本代码,用于检查设备类型并将其重定向到便利店。也就是说,如果设备是基于Android的,那么谷歌播放,如果该设备是基于ios的,则是appstore。

直到现在,我尝试了这一点,但它不起作用。

 < html> 
< head>
< script type =text / javascript>
$(document).ready(function()
{
if(navigator.userAgent.toLowerCase()。indexOf(android)> -1)
{
window.location.href ='http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
}
if(navigator。 userAgent.toLowerCase()。indexOf(iphone)> -1)
{
window.location.href ='http://itunes.apple.com/lb/app/truecaller-caller -id-number / id448142450?mt = 8';
}
}
< / javascript>
< / head>
< body>
< / body>
< / html>


解决方案 div>

问题出在你的脚本标记上,你缺少);



您是否导入了 jQuery

 < script src =http://code.jquery。 com / jquery-latest.min.jstype =text / javascript>< / script> 

< script>
$(document).ready(function(){
if(navigator.userAgent.toLowerCase()。indexOf(android)> -1){
window.location.href ='http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
}
if(navigator.userAgent.toLowerCase()。indexOf( iphone)> -1){
window.location.href ='http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
}
});
< / script>


I will send my clients the link for the app in the following format

http://goo.gl.com/downloadtheapp (or whatever)

I want this file be somewhere on my server that includes java script code that checks what is the device type and redirects to the convenient store. that is, google play if the device was android based and appstore if the device was ios based.

till now I tried this, but it does not work.

<html>
<head>
<script type="text/javascript">
        $(document).ready(function () 
    {
        if(navigator.userAgent.toLowerCase().indexOf("android") > -1)
        {
            window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
        }
        if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1)
        {
            window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
        }
    }
</javascript>
</head>
<body>
</body>
</html>

解决方案

the problem is with your script tag and you are missing );

and by the way did you imported jQuery?

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script>
    $(document).ready(function (){
        if(navigator.userAgent.toLowerCase().indexOf("android") > -1){
            window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
        }
        if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
            window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
        }
    });
</script>

这篇关于重定向到appstore或谷歌播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆