js 获取浏览器型号

根据浏览器获取iphone和apk的下载地址

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" content="text/html"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>测试</title>
    <style type="text/css">
      
    </style>
   
    <script type="text/javascript">
function getbrowse() {
var useragent = navigator.userAgent;
document.getElementById("phone").value=useragent;
if(useragent.indexOf("iPhone")>-1){
window.open('https://itunes.apple.com/cn/app/xxx/xxx?mt=8&ls=1');
return;
}
if(useragent.indexOf("Linux")>-1){
window.open('xx.apk');
}

}


</script>
</head>
<body onload="getbrowse()">
   <div >
        <label>型号</label><input id="phone" name="phone" style="width:500px" value=""  />
    </div>
</body>
</html>

你可能感兴趣的:(js,浏览器)