js判斷頁面是什麼設備打開的

function getBrowse() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
     //在微信客戶端打開
}android

if (ua.match(/WeiBo/i) == "weibo") {ios

   //在新浪微博客戶端打開微信

 }spa

 if (ua.match(/QQ/i) == "qq") {get

 //在QQ空間打開博客

}io

if (/android/i.test(ua)) {
//在android上打開微博

} else if (/mac os x/i.test(ua)) {
//在ios上打開function

}test

相關文章
相關標籤/搜索