javascript_浏览器对象

//javascript_浏览器对象

'use strict'
//window表示当前窗口
console.log('--------------------------window对象及其属性-----------------------------');
console.log('浏览器内宽度: ' + window.innerWidth);
console.log('浏览器内高度: ' + window.innerHeight);
console.log('浏览器外宽度: ' + window.outerWidth);
console.log('浏览器外高度: ' + window.outerHeight);

//navigator表示当前浏览器
console.log('--------------------------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);

//screen表示当前设备浏览器
console.log('--------------------------screen对象及其属性-----------------------------');
console.log('screen.width = ' + screen.width);
console.log('screen.height = ' + screen.height);
console.log('screen.colorDepth = ' + screen.colorDepth);

//location表示当前url
console.log('--------------------------location对象及其属性-----------------------------');
console.log('location.protocol = ' + location.protocol);
console.log('location.host = ' + location.host);
console.log('location.port = ' + location.port);
console.log('location.pathname = ' + location.pathname);

//document表示当前页面,是DOM树的根节点
console.log('--------------------------document对象及其属性-----------------------------');
document.title = '你看看,浏览器选项卡的文字是不是变化了';
console.log('document对象有1个cookie属性: ' + document.cookie);

// history对象
// 这个对象属于历史遗留对象,对于现代Web页面来说,由于大量使用AJAX和页面交互,简单粗暴地调用history.back()可能会让用户感到非常愤怒。
// 新手开始设计Web页面时喜欢在登录页登录成功时调用history.back(),试图回到登录前的页面。这是一种错误的方法。
// 任何情况,你都不应该使用history这个对象了。

  

猜你喜欢

转载自www.cnblogs.com/mexding/p/9003556.html