系统函数笔记

window.open()

window.open(“地址”,“打开方式”,“尺寸”)
window.open(‘test.html’, ‘_self’, ‘width=200, height=200’);
打开方式:
_blank新的窗口打开
_self在当前窗口打开

window.screen屏幕对象

availHeight 高度
availWidth 宽度

window.navigator浏览器对象

示例:
//判断用户使用的浏览器
var nv = window.navigator.userAgent;
if (nv.indexOf(‘Chrome’) != -1) {
alert(‘当前用户浏览器是谷歌’);
} else if (nv.indexOf(‘Firefox’) != -1) {
alert(‘当前用户浏览器是火狐’);
}else if (nv.indexOf(‘MSIE’) != -1 || isIE()) {
alert(‘当前用户浏览器是IE浏览器’);
};

function isIE() { // 判断是否是ie10的浏览器
if (!!window.ActiveXObject || “ActiveXObject” in window){
return true;
}else{
return false;
}
};

window.location地址对象

window.location.href = ‘test.html’;

window.history 历史对象

window.history.go(1); //前进
window.history.go(-1); //后退

localStorage 本地存储对象

存储对象, 可以用来存储数据, 和cookie相似, 区别是它是为了更大容量存储设计的, 在使用上也更加方便。
localStorage 数据一直存在
写入:
localStorage.setItem(‘name’,‘小王’);
读取:
localStorage.getItem(‘name’)
移除:
localStorage.removeItem(‘name’);
清空:
localStorage.clear();

sessionStorage浏览器存储对象

存储对象, 可以用来存储数据, 和cookie相似, 区别是它是为了更大容量存储设计的, 在使用上也更加方便
sessionStorage 当窗口关闭后 数据就被清空了
写入:
sessionStorage.setItem(‘name’,‘小王’);
读取:
sessionStorage.getItem(‘name’)
移除:
sessionStorage.removeItem(‘name’);
清空:
sessionStorage.clear();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值