屏蔽PC端访问JS代码 网站只允许手机端访问

更新时间:2024-01-12

js限制网页只在手机端中打开,网站屏蔽PC端访问JS代码,网站只允许手机端访问。

  1. <script type=“text/javascript”>

  2. if(window.screen.width==0){window.location.replace(“https://www.zhulitui.com”)};

  3. var system={win:false,mac:false,xll:false};

  4. var p = navigator.platform;

  5. system.win=p.indexOf(“Win”)==0;

  6. system.mac=p.indexOf(“Mac”)==0;

  7. system.x11=(p==“X11”) || (p.indexOf(“Linux”)==0);

  8. if(system.win||system.mac||system.xll) {

  9. location.replace(“http://这里替换为你需要跳转的页面网址”);

  10. }

  11. </script>