Browser - Object - Model
可以獲取頁(yè)面加載之外的,瀏覽器的一些信息。
-
navigator
navigator 中有 userAgent 的屬性,一般簡(jiǎn)稱(chēng) ua
這是一個(gè)瀏覽器特性,是一個(gè)字符串,里面包含了瀏覽器的一些信息。
一般用于檢測(cè)瀏覽器屬性比如:var ua = navigatior.userAgent var isChrome = ua.indexOf("Chrome") console.log(isChrome) //true or false
-
screen
一些關(guān)于屏幕的信息,能通過(guò) screen 獲取到
console.log(screen.width)
console.log(screen.height)
-
location
可以用于獲取當(dāng)前的 url 以及對(duì)該 url 進(jìn)行一些操作
console.log(location.href) // console.log(location.protocaol) // 協(xié)議 ‘http’ ‘https’ console.log(location.host) // 域名 console.log(location.pathname) // 路徑 console.log(location.search) // 查詢(xún) console.log(location.hash) // 哈希
-
history
控制歷史記錄的,一般用于瀏覽器前進(jìn)后退
history.back()
history.forward()
Wait me back