如何查找在哪个设备(移动设备(android 或 Ios)或桌面设备上打开了 Web 应用程序
How to find in which device (mobile(android or Ios) or desktop) the web application is opened
我正在使用 angularjs 开发 Web 应用程序项目,它也有移动应用程序,它们是 android 和 Ios。现在我想要在移动应用程序中打开 Web 应用程序时,我需要找到设备类型并检查是否安装了移动应用程序,如果安装应该在移动应用程序中打开,如果没有,则有应用程序的下载按钮-link.Thanks提前
使用 $window
服务,
你可以这样查
var userAgent = $window.navigator.userAgent;
/(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
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
}
}
我正在使用 angularjs 开发 Web 应用程序项目,它也有移动应用程序,它们是 android 和 Ios。现在我想要在移动应用程序中打开 Web 应用程序时,我需要找到设备类型并检查是否安装了移动应用程序,如果安装应该在移动应用程序中打开,如果没有,则有应用程序的下载按钮-link.Thanks提前
使用 $window
服务,
你可以这样查
var userAgent = $window.navigator.userAgent;
/(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
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
}
}