浏览器对象模型 --BOM--
1. window
alert()
confirm()
prompt()
setInterval()
setTimout()
2. location
href
hash
url
reload()
3. screen
4. history
alert, confirm, prompt
alert 用于窗口弹出
var a = window.confirm('你确定要离开网站?');
console.log(a);
var name = window.prompt('请输入你早晨吃了什么?','mjj');
console.log(name);
setTimeout(), setInterval()
延迟性的操作
window.setTimeout(function(){ //单次操作
console.log('mjj');
},2000)
var num = 0;
var timer = null;
timer = setInterval(funcition(){ //周期性的循环操作
num++;
if(num>5){
clearInterval(timer);
return;
}
console.log("num:" + num);
},1000)
location对象下的方法
console.log(location.host);
location.href = "url"; //跳转页面,会留下历史
location.replace("url"); // 跳转页面,不会留下历史
location.reload(); 重新加载
navigator对象
navigator.plugins
navigator.plugins[i].name.toLowerCase().indexOf(name) > -1?
查询浏览器支持的插件
history
history.go(2) 向前前进两个页面
history.go(-2) 后退两个页面
history.go() 刷新页面