BOM操作

BOM

BOM是Browser Object Module的简称。主要用来检测关于浏览器的特性。

API

navigator

检测浏览器类型
var ua = navigator.userAgent
var isChrome = ua.indexOf('Chrome')

location

浏览器url的操作
location.href //整个url字符串
location.protocol //协议http:
location.host //主机域名和端口号//www.imooc.com
location.pathname //域名下路径/learn/446
location.search //查询字段?user=abc&age=26
location.hash //hash值#mid=100

history

history.back() //后退
history.forward() //前进

screen

screen.width //屏幕宽度
screen.height //屏幕高度

你可能感兴趣的:(BOM操作)