Javascript 之 BOM

Browser  Object  Model

检测浏览器的类型

// navigator
var ua = navigator.userAgent;
var isChrome = ua.indexOf('Chrome');
console.log(isChrome);

screen

 

拆解 url 的各个部分

console.log(location.href);  // 完整的 URL
console.log(location.protocol);  // 协议 'http:' 或 'https:'
console.log(location.host);  // 域名
console.log(location.pathname);  // 路径
console.log(location.search);  // ? 后面参数
console.log(location.hash);  // # 后面参数

history

history.back();  // 
history.forward();  //

 

posted @ 2017-10-15 23:10  Joffy  阅读(116)  评论(0编辑  收藏  举报