JS复习(二)

1.BOM

1.Windows

1.windows对象浏览器的实例(Global对象)

2.通过var声明的所有全局变量和函数都会变成Windows对象的属性和方法,所以使用let,const来替代

3.窗口大小,innerWidth,innerHeight (页面),outreWidth,outerHeight(窗口)

3.定时器setTimeout,js是单线程的,js维护了一个任务队列,其中任务会按照添加到队列的先后顺序执行,sto的参数,只是多长时间后把这个任务添加到队列,setInterval()会每隔固定时间段,将任务加到队列中

let num=0,intervalid=null;
let max=10;
 let increment1 = function () {
    num++;
    console.log(num);
    if(num==max){
        clearInterval(intervalid);
        console.log('====================================');
        console.log('Done');
        console.log('====================================');
    }
}
intervalid=setInterval(increment1, 500); 
let increment = function () {
    num++;
    console.log(num);
    if(num<max){
        setTimeout(increment,500)
        
    }else{
        console.log('Done');
    }
}
setTimeout(increment,500)

4.系统对话框1.alert,confrim,prompt

2.location对象

1.提供当前窗口种加载文档的信息,以及通常的导航功能,它既是windows,也是document的属性,location对象不仅保存着当前加载文档的信息,也保存着把url解析成为离散片段后能通过属性访问的信息

url:http://foouser:password@www.wst.com:80/JHBB/?q=javascript#content

location.hash

#content

hostwww.wst.com:80
hostnamewww.wst.com
hrefhttp://www.wst.com:80/JHBB/?q=javascript#content
pathname/JHBB/
port80
protocolhttp:
search?q=javascript
usernamefoouser
passwordpassword
originhttp://www.wst.com

2.

let q='?q=javascript&num=10&name=wst'
let args=new URLSearchParams(q)
console.log(args.has('name'));
console.log(args.get('name'));
args.set('page',3)
console.log(args.toString());
args.delete('page')
console.log(args.toString());
//true
wst
q=javascript&num=10&name=wst&page=3
q=javascript&num=10&name=wst

3.操作地址,location.assign()

修改url后,浏览器历史记录中就会增加相应记录,后退,可以导航到上个页面,如果不希望增加可以使用replace()

3.navigator

1.客户端识别浏览器的标准,通常用于确认浏览器的类型

2.插件检测,plugins,windows.navigator.plugins

4.screen

5.history

1.导航history.go(-1) history.back() history.forward() history.go(xxx)

2.历史状态管理

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值