访问浏览器判断是android还是ios系统或者是pc端

通过javaScript用来判断设备类型

function open_or_download_app() {
      // alert(navigator.userAgent);
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
            window.location.href = "http://www.google.cn ";
        } else if (/(Android)/i.test(navigator.userAgent)) {
            window.location = "http://www.baidu.com ";   
        } else {
            window.location = "https://www.so.com ";
        }
    };

你可能感兴趣的:(JavaScript)