~~~ function isMobile() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; return bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM; } <script src="https://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script> if(isMobile()){ mqq.ui.openUrl({target: 2,url: "alipays://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=https%3a%2f%2fqr.alipay.com%2fc1x05319riy635sbi3af7ce%3f_s%3dweb-other"}); }else { layer.msg('请在手机QQ中打开~'); } mqq.ui.addShortcut({ action: 'web', title: '支付宝红包技术', icon: 'https://***.com/redbag.png', url: 'https://***.com/redbag.php' }); ~~~ 获取浏览器类型 ~~~ var getBrowserInfo = function(){ var ua = navigator.userAgent.toLocaleLowerCase(); var browserType=null; if (ua.match(/msie/) != null || ua.match(/trident/) != null) { browserType = "IE"; browserVersion = ua.match(/msie ([\d.]+)/) != null ? ua.match(/msie ([\d.]+)/)[1] : ua.match(/rv:([\d.]+)/)[1]; } else if (ua.match(/firefox/) != null) { browserType = "火狐"; }else if (ua.match(/ubrowser/) != null) { browserType = "UC"; }else if (ua.match(/opera/) != null) { browserType = "欧朋"; } else if (ua.match(/bidubrowser/) != null) { browserType = "百度"; }else if (ua.match(/metasr/) != null) { browserType = "搜狗"; }else if (ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null) { browserType = "QQ"; }else if (ua.match(/maxthon/) != null) { browserType = "遨游"; }else if (ua.match(/chrome/) != null) { var is360 = _mime("type", "application/vnd.chromium.remoting-viewer"); function _mime(option, value) { var mimeTypes = navigator.mimeTypes; for (var mt in mimeTypes) { if (mimeTypes[mt][option] == value) { return true; } } return false; } if(is360){ browserType = '360'; }else{ browserType = 'chrome'; } }else if (ua.match(/safari/) != null) { browserType = "Safari"; } return browserType; } ~~~