1 var system ={}; 2 var p = navigator.platform; 3 system.win = p.indexOf("Win") == 0; 4 system.mac = p.indexOf("Mac") == 0; 5 system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); 6 if(system.win||system.mac||system.xll){//如果是电脑跳转到百度 7 window.location.href="http://www.baidu.com/"; 8 }else{ //如果是手机,跳转到谷歌 9 window.location.href="http://www.google.cn/"; 10 }