开发者

Call function first time after specified time interval

I am using Firefox and I want to call a function (Logger) 10 seconds after the page has loaded. I am using this code

if (document.addEventListener)
  document.addEventListener("DOMConte开发者_高级运维ntLoaded", Logger, false)

Any advice?


You can do like this:

window.onload = function(){
  setTimeout("func_name", 10000);
};

Where func_name is normal function:

function func_name(){
 // code here...
}

Or you can even do this:

window.onload = function(){
  setTimeout(function(){
     // your code...
  }, 10000);
};

More Info:

  • http://www.w3schools.com/jsref/met_win_settimeout.asp
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜