javascript window对象

window.navigator:

var appName = navigator.appName;// 浏览器名称
var appVersion = navigator.appVersion;// 浏览器版本
var language = navigator.language;// 浏览器语言
var platform = navigator.platform;// 浏览器平台
var userAgent = navigator.userAgent;// 浏览器User-Agent字符串

window对象有innerWidthinnerHeight属性,可以获取浏览器窗口的内部宽度和高度。内部宽高是指除去菜单栏、工具栏、边框等占位元素后,用于显示网页的净宽高

兼容性:IE<=8不支持。

所以代码可以这么写:

var width = window.innerWidth || document.body.clientWidth;

 

window.screen

screen.width:屏幕宽度,以像素为单位;

screen.height:屏幕高度,以像素为单位;

screen.colorDepth:返回颜色位数,如8、16、24。

 

window.location

var url = 'http://www.xxx.com:8080/path/index.html?page=1&id=2#toHere';

location.protocol; // 'http'
location.host; // 'www.xxx.com'
location.port; // '8080'
location.pathname; // '/path/index.html'
location.search; // '?page=1&id=2'
location.hash; // 'toHere'

要加载一个新页面,可以调用location.assign()。如果要重新加载当前页面,调用location.reload()方法非常方便。

 

window.document

DOM树

 

转载于:https://www.cnblogs.com/Zell-Dinch/articles/5160679.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值