全局变量:
定义在外边的变量
若没有用var声明,则当这行赋值运行,则就将他认为是全局变量。
局部变量
在函数内部里声明的变量,只能在该函数里有效。
BOM对象
window对象的方法
prompt\alert\confirm\close\open\settimeout\setinterval\
clearinterval\cleartimeout
settimeout:
function timeout(){
var toast=function(){
alert('我弹出来了');
}
setTimeout(toast,3000); //3秒以后执行一次
}
setinterval:
var showtime=function(){
//显示当前的时间
var p1=document.getElementById('p1');
var data=new Date();
p1.innerText=data;
}
setInterval(showtime,1000) //每隔1秒就执行
clearinterval:
onload=function(){
var showtime=function(){
//显示当前的时间
var p1=document.getElementById('p1');
var data=new Date();
p1.innerText=data;
}
a=setInterval(showtime,1000)
}
function cle(){
clearInterval(a);
}
open:
open('ch_js_05.html','','width=300,height=200,menubar=no');