当前位置: 首页 > Web与应用 > 正文

之前发过,https://blog.ich8.com/post/3654,根据discuz x3.1的文件进行小小的改动,完善根据ua的识别。

 

//判断浏览器User-Agent
function is_mobile() {
var regex_match = /(iphone|android|phone|mobile|wap|netfront|java|opera mobi|opera mini|ucweb|windows ce|symbian|series|webos|sony|blackberry|dopod|nokia|samsung|palmsource|xda|pieplus|meizu|midp|cldc|motorola|foma|docomo|up.browser|up.link|blazer|helio|hosin|huawei|novarra|coolpad|webos|techfaith|palmsource|alcatel|amoi|ktouch|nexian|ericsson|philips|sagem|wellcom|bunjalloo|maui|smartphone|iemobile|spice|bird|zte-|longcos|gionee|portalmmm|jig browser|hiptop|benq|haier|^lct|320×320|240×320|176×220|windows phone|cect|compal|ctl|lg|nec|tcl|ericsson|daxian|dbtel|eastcom|pantech|konka|kejian|lenovo|mot|soutec|sgh|sed|capitel|panasonic|sonyericsson|sharp|panda|zte)/i;
var u = navigator.userAgent;
if (null == u) {
return true;
}
var result = regex_match.exec(u);
if (null == result) {
return false
} else {
return true
}
}
if (is_mobile()) {
document.location.href= ‘../mobile/login.html’;
}

 

[分享]javascript 识别移动客户端:等您坐沙发呢!

发表评论