首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重定向至应用商店或google play

重定向至应用商店或google play
EN

Stack Overflow用户
提问于 2014-06-28 15:21:05
回答 1查看 42K关注 0票数 24

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

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

我希望这个文件在我的服务器上的某个地方,其中包括java脚本代码,检查什么是设备类型,并重定向到便利店。也就是说,如果设备是基于android的,则为google play;如果设备是基于ios的,则为appstore。

到目前为止,我尝试了这个,但它不起作用。

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-28 16:38:46

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

顺便问一下,您是否导入了jQuery

代码语言:javascript
复制
<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>
票数 41
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24464602

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档