判断pc端或移动端并跳转
判断pc端或移动端并跳转
代码目录:
index.html代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag; } var flag = IsPC(); if(flag){ window.location.href="./studentp/index.html#/"; }else { window.location.href="./studenti/index.html#/"; }</script> </body> </html>
参考自:http://www.jb51.net/article/48939.htm