• 请不要在回答技术问题时复制粘贴 AI 生成的内容
frontman
V2EX  ›  程序员

h5 页面怎么判断页面是在支付宝里?

  •  
  •   frontman · Sep 12, 2016 · 15825 views
    This topic created in 3530 days ago, the information mentioned may be changed or developed.
    在微信里可以通过 userAgent 判断里面是否有 micromessage 这个字符串,支付宝可以通过这种方式么
    5 replies    2016-09-12 17:55:40 +08:00
    zjq426
        1
    zjq426  
       Sep 12, 2016
    支付宝: Mozilla/5.0 (Linux; U; Android 5.1.1; en-us; KIW-AL10 Build/HONORKIW-AL10) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/1.0.0.100 U3/0.8.0 Mobile Safari/534.30 AlipayDefined(nt:WIFI,ws:360|592|3.0) AliApp(AP/9.5.3.030408) AlipayClient/9.5.3.030408 Language/zh-Hans

    网上找的,不一定对
    raycool
        2
    raycool  
       Sep 12, 2016
    fakefish
        3
    fakefish  
       Sep 12, 2016   ❤️ 3
    confirm('您在使用支付宝么?');
    laiqs2011
        4
    laiqs2011  
       Sep 12, 2016
    ```
    let payEnv;
    // 判断微信还是支付宝
    if (/MicroMessenger/.test(window.navigator.userAgent)) {
    // 微信
    payEnv = 'weixin';
    } else if (/AlipayClient/.test(window.navigator.userAgent)) {
    // 支付宝
    payEnv = 'alipay';
    } else {
    payEnv = 'others';
    }

    ```
    mokeyjay
        5
    mokeyjay  
       Sep 12, 2016
    记得支付宝内置浏览器的 UA 里有个 AlipayClient
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5947 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 02:53 · PVG 10:53 · LAX 19:53 · JFK 22:53
    ♥ Do have faith in what you're doing.