核心提示:dom04设置定时器,定时器:定时执行var timerld=setInterval(code.interval);clearInterval(timerld);间隔时间执行,不是特别精确延迟执行va...
dom04设置定时器,定时器:
定时执行
var timerld=setInterval(code.interval);
clearInterval(timerld);
间隔时间执行,不是特别精确
延迟执行
var timerld=setTimeout(code.interval);
clearTimeout(timerId);
//btn1设置延时定时器 //延时定时器 setTimeout(1回调函数2延迟的时间单位是毫秒) //间歇定时器 setInterval(1回调函数,2时间间隔单位是毫秒); 间歇定时器 var timerId=null; var btn1=document.getElementById('btn1'); var btn2=document.getElementById('btn2'); btn1.onclick=function(){ setTimeout(function () { console.log("boom"); },3000); }; btn2.onclick=function(){ //清除定时器 clearTimeout(timerId); };
window.open(1地址,2哪里打开,3窗口的属性).
var win=window.open("https://www.baidu.com","_blank","width=200,height=200"); btn.onclick=function(){ //1地址,2哪里打开,3窗口的属性 //window.open("https://www.baidu.com","_blank");//在新的空白窗口打开 //window.open("https://www.baidu.com","_self");//在当前窗口打开 window.open("https://www.baidu.com","_blank","width=200,height=200");//在新的空白窗口打开 } win.close();//关闭当前窗口。