js实现打开网页设备判断

来源:互联网 发布:咪蒙致贱人 知乎 编辑:程序博客网 时间:2024/05/16 06:14
<!DOCTYPE html><html><head><meta charset=utf-8" /><title>js实现打开网页设备判断</title><script>/*判断打开设备*/var system ={  win : false,  mac : false,  xll : false };  //检测平台   var p = navigator.platform;  system.win = p.indexOf("Win") == 0;  system.mac = p.indexOf("Mac") == 0;  system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); var local= location.href;//跳转语句   if(system.win||system.mac||system.xll){//此处说明打开该网页设备为pc端alert("该设备为PC端");//若用移动端网址路径访问则自动跳转到对应pc端路径if(local=='http://www.centlight.com/mobile_web.html'){window.location.href="http://www.centlight.com/child_web.html";}else if(local=='http://www.centlight.com/mobile_ui.html'){window.location.href="http://www.centlight.com/child_ui.html";}else if(local=='http://www.centlight.com/mobile_php.html'){window.location.href="http://www.centlight.com/child_php.html";}else{window.location.href="http://www.centlight.com/";}  }else{//此处说明打开该网页设备为移动端alert("该设备为移动端");//若用PC端网址路径访问则自动跳转到对应移动端路径if(local=='http://www.centlight.com/child_web.html'){window.location.href="http://www.centlight.com/mobile_web.html";}else if(local=='http://www.centlight.com/child_ui.html'){window.location.href="http://www.centlight.com/mobile_ui.html";}else if(local=='http://www.centlight.com/child_php.html'){window.location.href="http://www.centlight.com/mobile_php.html";}else{window.location.href="http://www.centlight.com/mobile.html";}}</script></head><body></body></html>

0 0
原创粉丝点击