js实现判断访问设备是电脑还是手机?

function IsPhone(){
    var info = navigator.userAgent;
    var isPhone = /mobile/i.test(info);
    return isPhone;
}