zoukankan      html  css  js  c++  java
  • setInterval/setTimeout传参方法

    网上文章说有3种方法,对于我来说一种方法就够了:

    <script> 
    var user_name='离间计'
    //定时器 异步运行 
    function hello(name){ 
    alert(name); 
    } 
    //使用方法名字执行方法 
    var t1 = window.setTimeout(hello,1000,user_name); 
    window.clearTimeout(t1);//去掉定时器 
    </script> 
    
    <script> 
    var user_name='离间计'
    //定时器 异步运行 
    function hello(name){ 
    alert(name); 
    } 
    //使用方法名字执行方法 
    var t1 = setInterval(hello,1000,user_name); 
    setInterval(t1);//去掉定时器 
    </script> 

    附下函数原型

    /**
    @param {number} intervalId
    */
    Window.prototype.clearInterval = function(intervalId) {};
    /**
    @param {number} intervalId
    */
    Window.prototype.clearTimeout = function(intervalId) {};
    /**
    @param {String|Function} code
    @param {number} [delay]
    @param {...*} [arguments]
    @return {number}
    */
    Window.prototype.setInterval = function(code,delay,arguments) {};
    /**
    @param {String|Function} code
    @param {number} [delay]
    @param {...*} [arguments]
    @return {number}
    */
    Window.prototype.setTimeout = function(code,delay,arguments) {};
    /**
    @browser Gecko
    @param {Event} eventType
    @return {void}
    @deprecated
    */
  • 相关阅读:
    资源-python 视频下载大全
    ubuntu 16.04(操作应用) -软件卸载
    资源-简历的相关知识
    centos (命令操作)-crontab命令
    ubuntu 16.04 (软件应用)-输入法
    ntp时间同步
    lvm空间扩容
    目录知识
    Linux下安装maven
    elasticsearch安装pinyin模块
  • 原文地址:https://www.cnblogs.com/shengulong/p/7372415.html
Copyright © 2011-2022 走看看