V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
maruize321
V2EX  ›  程序员

js 怎么判断 Line 和 facebook 啊

  •  
  •   maruize321 · 2019-11-25 15:34:59 +08:00 · 2298 次点击
    这是一个创建于 1585 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题,查了半天查不到

    1 条回复    2019-11-25 16:24:01 +08:00
    cheeto
        1
    cheeto  
       2019-11-25 16:24:01 +08:00   ❤️ 1
    你指的是在 line 或 FB 中打开么。。。
    用 UA
    ```
    var versions = function (){
    var u = navigator.userAgent, app = navigator.appVersion;
    var ua = navigator.userAgent.toLowerCase();

    return { //偵測移動端瀏覽器版本信息
    trident: u.indexOf('Trident') > -1, //IE 核心
    presto: u.indexOf('Presto') > -1, //opera 核心
    webKit: u.indexOf('AppleWebKit') > -1, //Apple, google 核心
    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //Firefox 核心
    mobile: !!u.match(/AppleWebKit.*Mobile.*/), //行動裝置
    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
    webApp: u.indexOf('Safari') == -1, //是否 web 应该程序,没有头部与底部
    iosv: u.substr(u.indexOf('iPhone OS') + 9, 3),//ios 版本
    weixin: ua.match(/MicroMessenger/i) == "micromessenger",//微信瀏覽器
    fbapp: u.indexOf('FBAV') > -1,//Facebook App 內瀏覽器
    line: u.indexOf('Line') > -1//Line 內瀏覽器
    };
    }();

    // redir to mobile version
    if( versions.mobile ){
    location.href = 'https://' + location.hostname + '/mobile.html';
    }

    // inside of weixin app
    if( versions.weixin ){

    }else{

    }
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5677 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 06:28 · PVG 14:28 · LAX 23:28 · JFK 02:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.