jwangkun
V2EX  ›  问与答

如何实现一个二维码跳转到连个应用市场(自动识别 Android 和 ios)?

  •  
  •   jwangkun · Dec 19, 2014 · 5872 views
    This topic created in 4178 days ago, the information mentioned may be changed or developed.
    我的想法是做一个页面通过js判断一下,然后识别后自动跳转,有没有有其他的更好的办法?js实现的话怎么写js自动识别ios Andriod?能贴上代码最好,谢谢
    4 replies    2014-12-19 12:02:32 +08:00
    jwangkun
        1
    jwangkun  
    OP
       Dec 19, 2014   ❤️ 1
    <html>
    <title></title>
    <head></head>
    <body>
    <script type="text/javascript">
    var browser = {
    versions: function () {
    var u = navigator.userAgent, app = navigator.appVersion;
    return { //移动终端浏览器版本信息
    ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
    iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
    iPad: u.indexOf('iPad') > -1, //是否iPad
    };
    }(),
    }
    if (browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) {
    window.location.href = "https://itunes.apple.com/cn/app/qq/id444934666?mt=8&v0=WWW-GCCN-ITSTOP100-FREEAPPS&l=&ign-mpt=uo%3D4";
    }
    if (browser.versions.android) {
    window.location.href = "http://www.qq.com";
    }
    </body>
    </html>
    这样行吗
    kookxiang
        3
    kookxiang  
       Dec 19, 2014
    最好直接用302跳转吧,也是判断浏览器UA跳转
    xwsoul
        4
    xwsoul  
       Dec 19, 2014
    简单说就是二维码进landing page, Landing page 识别定向转发
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3369 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 466ea39e · 36ms · UTC 11:13 · PVG 19:13 · LAX 04:13 · JFK 07:13
    ♥ Do have faith in what you're doing.