【问题标题】:How to find in which device (mobile(android or Ios) or desktop) the web application is opened如何查找在哪个设备(移动设备(Android 或 Ios)或桌面)中打开了 Web 应用程序
【发布时间】:2016-09-07 13:01:22
【问题描述】:

我正在使用 angularjs 开发 Web 应用程序项目,它也有移动应用程序,它们是 android 和 Ios。现在我想当网络应用程序在移动设备中打开时我需要找到设备类型并检查移动应用程序是否安装,如果安装应该在移动应用程序中打开,如果没有下载按钮用于应用程序链接。谢谢前进

【问题讨论】:

标签: android jquery ios angularjs mobile


【解决方案1】:
function checkOperatingSystem()
{  var userAgent = navigator.userAgent || navigator.vendor || window.opera;

    //Check mobile device is Android
    if (/android/i.test(userAgent)) {
        //Add your Code here
    }

    //Check mobile device is IOS
    if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
        //Add your Code here
    }

    //Check device os is Windows (For Laptop and PC)
    if (navigator.appVersion.indexOf("Win")!=-1)
    {
        //Add your Code here
    }

    //Check device os is MAC (For Laptop and PC)
    if (navigator.appVersion.indexOf("Mac")!=-1)
    {
        //Add your Code here
    }
}

【讨论】:

    【解决方案2】:

    使用$window 服务,

    你可以像这样检查

    var userAgent = $window.navigator.userAgent;
    
    /(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
    

    【讨论】:

      猜你喜欢
      • 2016-03-12
      • 1970-01-01
      • 2021-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多