看到别人有人发,然后要回复等要求,心里不是滋味。我就直接放代码供大家参考使用了【无需任何要求,直接分享生成HTML后手机访问网页自动跳3G】
代码放首页<head></head>间,生成不生成都会手机访问跳转3G
- <meta name="mobile-agent" content="format=xhtml; url=/3g/" /><script type="text/javascript">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";if (!bIsIpad && (bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)) { window.location.href = "/3g/";}</script>