前端JS知识要点总结(7)

来源:互联网 发布:mysql not in用法 编辑:程序博客网 时间:2024/05/22 08:15

BOM

Browser Object Model

知识点:

  • navigator
  • screen
  • location
  • history

可以通过history.back()和history.forward()来控制浏览器前进后退

题目二十三:如何检测浏览器的特性

检查是否为Chrome浏览器

var ua = navigator.userAgentvar isChrome = ua.indexOf('Chrome')console.log(isChrome)

检查显示器屏幕大小

screen.widthscreen.height

题目二十四:拆解url的各部分

这一题结合location来说明一下:
以下面这个网址为例

http://coding.imooc.com/lesson/115.html#mid=5277

location.href // "http://coding.imooc.com/lesson/115.html#mid=5277"location.protocol // "http:"location.host // "coding.imooc.com"location.pathname // "/lesson/115.html"location.search // ""location.hash // "#mid=5277"
原创粉丝点击