Wap browsing automatically jumps to the js code of the wap page

  • 2020-03-30 02:59:43
  • OfStack

How to allow users to enter the wap mobile website url automatically redirect to wap website?
Wap page automatically jump to achieve the way?
How to determine whether a visitor is visiting from a mobile device and automatically jump to a wap page?
Mobile phone automatically jump to the mobile phone page, a url to distinguish between ordinary access and mobile phone access?
How to automatically redirect to wap page when accessing website domain name on mobile phone?

This article can solve these problems!


function is_mobile() { 
    var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|jigs browser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/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= '/wap'; 
 }

The above is the js code just need to change /wap to the page you want to jump to


Related articles: