You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
978 B

2 years ago
  1. <html lang="en">
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. </body>
  10. <script type="text/javascript">
  11. var redirect = () => {
  12. // 获取设备信息
  13. let userAgent = navigator.userAgent.toLowerCase();
  14. // 正则表达式,判断有没有出现这些设备的类型
  15. let device = /ipad|iphone|midp?rv:1.2.3.4|ucweb|android|window ce|window mobile/;
  16. // 判断获取的设备信息与正则表示式的规则有没有匹配的,如果有匹配的,则跳转到移动端,没有就跳转到 PC 端
  17. if (device.test(userAgent)) {
  18. // 跳转到移动端页面
  19. window.location.href = "move.html";
  20. } else {
  21. // 跳转 pc 端页面
  22. window.location.href = "pc.html"
  23. }
  24. }
  25. redirect()
  26. </script>
  27. </html>