zoukankan      html  css  js  c++  java
  • Javascript 定时器

    在js中定时器分两种:setTimeout()和setInterval()

    1.setTimeOut():只在指定时间后执行一次

    /定时器 异步运行  
    function hello(){  
    alert("hello");  
    }  
    //使用方法名字执行方法  
    var t1 = window.setTimeout(hello,1000);  
    var t2 = window.setTimeout("hello()",3000);//使用字符串执行方法  
    window.clearTimeout(t1);//去掉定时器

    2.setInterval():以指定时间为周期循环执行

    /实时刷新  时间单位为毫秒  
    setInterval('refreshQuery()',8000);   
    /* 刷新查询 */  
    function refreshQuery(){  
      console.log('每8秒调一次') 
    }
  • 相关阅读:
    杭电1827
    hdu 3118
    poj 2060
    hdu 2236
    poj 2226
    poj 1719
    poj 1466
    poj 3160
    骑士飞行棋笔记
    基础测试学习笔记
  • 原文地址:https://www.cnblogs.com/s593941/p/9786577.html
Copyright © 2011-2022 走看看