js判断是否安桌是否ios
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title></title> <!-- CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous"> <!-- 最新版本的 Bootstrap 核心 CSS 文件 --> <!-- jQuery and JavaScript Bundle with Popper --> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-LCPyFKQyML7mqtS+4XytolfqyqSlcbB3bvDuH9vX2sdQMxRonb/M3b9EmhCNNNrV" crossorigin="anonymous"></script> </style> <script type="text/javascript"> var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核 mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1|| u.indexOf('Linux') > -1, //android终端 iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器 iPad: u.indexOf('iPad') > -1, //是否iPad Chrome: u.indexOf('Chrome') > -1, //是否安桌 webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部 weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增) qq: u.match(/\sQQ/i) == "qq" //是否QQ }; }(), language:(navigator.browserLanguage || navigator.language).toLowerCase() } $(document).ready(function () { if (browser.versions.android ) { $("#btnios").hide(); window.location.href = "https://play.google.com/store/apps/details?id=com.hisilicon.dashcam"; $("#btnandroid").show(); } else if ( browser.versions.ios || browser.versions.iPhone || browser.versions.iPad) { $("#btnandroid").hide(); window.location.href = "https://apps.apple.com/cn/app/koool-camera/id1488372912"; $("#btnios").show(); } else if(browser.versions.mobile) { // alert('移动端'); $("#btnios").show(); $("#btnandroid").show(); } }); </script> </head> <body> </body> </html>
本文来自博客园,作者:willamyao,转载请注明原文链接:https://www.cnblogs.com/robertyao/p/14708503.html
代码改变世界