BOM

2017-04-01  本文已影响0人  3hours

6.BOM

1.window

window.innerWidth

window.innerHeight 页面可视区宽高,不兼容低版本浏览器

document.documentElement.clientWidth;网页可见区域宽

document.documentElement.clientHeight;网页可见区域高

2.screen 包含用户显示器的硬件

3.location 地址栏

loaction.href = "http://www.sina.com" 跳转

location.search 地址栏?之后的请求参数

location.hash 地址栏#号之后的内容

location.reload() 刷新

4.弹窗

alert/prompt

var yourname = prompt("请输入你的名字?");//prompt有返回值 是用户输入的内容

confirm("") //返回值为boolean类型

5.history 历史记录

history.forward() 前进  history.go(1)

history.back()   后退  history.go(-1)

history.go(1)

6.navigator 导航信息

navigator.userAgent 用户代理,早期的浏览器嗅探使用该属性

IE7检测 navigator.userAgent().toLowerCase().indexOf("msie")> -1

navigator.userAgent 检测pc端/移动端 是否包含"mobile"字符

navigator.userAgent 检测浏览器

上一篇下一篇

猜你喜欢

热点阅读