随着多终端的发展,为了迎合网民的体验感,很多企业在不同终端做了相应的网站,所以在不同的终端下也就有了根据不同的类型显示相应的展示内容,下面就是用JS判断浏览器不同客户端类型,跳转至指定的页面。
1 <script type="text/javascript"> 2 var sUserAgent = navigator.userAgent.toLowerCase(); 3 var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; 4 var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; 5 var bIsMidp = sUserAgent.match(/midp/i) == "midp"; 6 var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; 7 var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; 8 var bIsAndroid = sUserAgent.match(/android/i) == "android"; 9 var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; 10 var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; 11 if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM ) 12 { 13 window.location.href="http://www.029qq.net/2017/10/yxlm_wap/"; 14 } 15 </script>