js判断手机访问直接跳转手机版网站

function uaredirect(murl){

try {

if(document.getElementByIdx_x("bdmark") != null){

return;

}

var urlhash = window.location.hash;

if (!urlhash.match("fromapp")){

if ((navigator.userAgent.match(/iphone|android|phone|mobile|wap|netfront|x11|java|operamobi|operamini|ucweb|windowsce|symbian|symbianos|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|pantech|gionee|portalmmm|jig browser|hiptop|benq|haier|^lct|320x320|240x320|176x220/i))) {

location.replace(murl);

}

}

} catch(err){}

}

uaredirect("https://wap.yoursite.com");

评论

© ID4710720 | Powered by LOFTER