常用的BOM Api:
- window
- screen
- location
- navigator
- document
- history(已弃用)
window、screen
// 纯HTML内容区域的宽高(不包括收藏夹,导航栏等)
window.innerHeight;
window.innerWidth;
// 包含收藏夹、导航栏、边框等元素的视窗宽高
window.outerHeight;
window.outerWidth;
// 与浏览器无关,只跟屏幕有关的(固定的)宽高
screen.height;
screen.width;
location
// 与URL相关的信息
/*
http://www.example.com:8080/path/index.html?a=1&b=2#TOP
*/
location.protocol; // 'http'
location.host; // 'www.example.com'
location.port; // '8080'
location.pathname; // '/path/index.html'
location.search; // '?a=1&b=2'
location.hash; // 'TOP'
navigator
// 与浏览器相关的信息
console.log('appName = ' + navigator.appName);
console.log('appVersion = ' + navigator.appVersion);
console.log('language = ' + navigator.language);
console.log('platform = ' + navigator.platform);
console.log('userAgent = ' + navigator.userAgent);
// appName = Netscape
// appVersion = 5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
// language = zh-CN
// platform = Win32
// userAgent = Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。