站内搜索:
首页 >> 前端 >> 内容
dom04设置定时器

时间:2017/3/28 9:55:00

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();//关闭当前窗口。

  • 上一篇:常见浏览器兼容性问题与解决方案
  • 下一篇:php百度地图api接入——页面html部分
  • 返回顶部