主要包含
console.log(navigator);/*有关访问者浏览器的信息*/
console.log(location);/*取到浏览器的URL地址信息*/
console.log(history);/*浏览历史记录*/
效果如下:
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BOM浏览器对象模型</title>
<script type="text/javascript">
console.log(navigator);/*有关访问者浏览器的信息*/
console.log(location);/*取到浏览器的URL地址信息*/
console.log(history);/*浏览历史记录*/
var ua = navigator.userAgent;
/*判断所使用的浏览器类型*/
if(/firefox/i.test(ua)){
alert("你是火狐");
}
else if(/chrome/i.test(ua)){
alert("你是谷歌");
}
/*切换到其它页面*/
// location.replace("图片拖动.html");/*同一级下的页面*/
/*死循环*/
// history.back();/*页面返回:*/
// history.forward();/*页面返回:*/
// history.go(-2);/*页面返回到上两节*/
</script>
</head>
<body>
</body>
</html>