网站PC端和移动端,用户通过设备识别

 1 <!DOCTYPE html>
 2 <html>
 3   <head>
 4     <meta charset="utf-8">
 5     <!--<meta name="viewport" content="width=device-width,initial-scale=1.0">-->
 6     <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
 7 
 8     
 9 
10     <title>website</title>
11   </head>
12   <body>
13 
14   </body>
15 
16 <script>
17 function IsPC() {
18     var userAgentInfo = navigator.userAgent;
19     var Agents = ["Android", "iPhone",
20                 "SymbianOS", "Windows Phone",
21                 "iPad", "iPod"];
22     var flag = true;
23     for (var v = 0; v < Agents.length; v++) {
24         if (userAgentInfo.indexOf(Agents[v]) > 0) {
25             flag = false;
26             break;
27         }
28     }
29     return flag;
30 }
31  
32 var flag = IsPC(); 
33 
34 if(flag){
35 console.log("sdasd")
36 window.location.href="pc/index.html"
37 
38 }else{
39 console.log(flag)
40 window.location.href="mobile/index.html"
41 
42 }
43 </script>
44 
45 </html>

 

网站PC端和移动端,用户通过设备识别

上一篇:Android-App性能测试工具GT的使用方法


下一篇:pandas处理时间序列(4): 移动窗口函数