location 对象 navigator的应该 (获取浏览器名称和版本信息)
<script>
console.log("appName"+navigator.appName);
console.log("appVersion"+navigator.appVersion);
console.log("platform"+navigator.platform);
console.log("userAgent"+navigator.userAgent) ;
function validB(){
var u_agent = navigator.userAgent ;
var B_name="不是想用的主流浏览器!";
if(u_agent.indexOf("Firefox")>-1){
B_name="Firefox";
}else if(u_agent.indexOf("Chrome")>-1){
B_name="Chrome";
}else if(u_agent.indexOf("MSIE")>-1&&u_agent.indexOf("Trident")>-1){
B_name="IE(8-10)";
}
else if(u_agent.indexOf("Trident")>-1){
B_name="IE(11)";
}
var a= u_agent.substring( u_agent.indexOf(B_name),u_agent.length);
document.write("浏览器:"+B_name+"<br>");
document.write("u_agent:"+a+"<br>");
}
</script>
<form>
<input type="button" value="查看浏览器" onclick="validB()">
</form>