超时调用setTimeout(fn, time);第一个参数也可以是字符串,不过会导致性能损失,不推荐使用;第二个参数是毫秒值,经过这段时间后执行函数fn。setTimeout是一次性的,也就是只执行一次代码。
间歇调用setInterval(fn, time);与setTimeout参数上没什么区别,区别就在于setInterval隔time时间就执行一次代码。注意:后一个间歇调用有可能会在前一个间歇调用结束之前启动
系统提示框alert();confirm();prompt();
Location
假设地址为:http://www.mytest.com:80/index.html?userName=哈哈&pwd=123456#123
window.location.hash-->#后面
window.location.host-->主机名及端口号www.mytest.com:80
window.location.hostname-->主机名www.mytest.com
window.location.port-->端口号80(如果有)
window.location.pathname-->文件相对路径/index.html
window.location.protocol-->协议http:
window.location.search-->?后面直至# ?userName=哈哈&pwd=123456
上述代码获取值之外还可以设置值,除了设置hash之外,其他设置完后都会刷新页面
location.href = URL ; location.assign(URL); 跳转页面,可后退
location.replace(); 代替当前页面,不可后退
location.reload(); 相当于页面刷新
Navigator(只列了两个)
window.navigator.platform-->浏览器所在的操作系统
window.navigator.userAgent-->浏览器用户代理字符串
History
window.history.forward(); 前进
window.history.back(); 后退
window.history.go(0); -1-->后退;0-->当前;1-->前进
window.history.length-->历史记录的数量