最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Call function first time after specified time interval - Stack Overflow

programmeradmin0浏览0评论

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("DOMContentLoaded", Logger, false)

Any advice?

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("DOMContentLoaded", Logger, false)

Any advice?

Share Improve this question asked Nov 7, 2010 at 8:17 RefRef 331 silver badge3 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

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./jsref/met_win_settimeout.asp
发布评论

评论列表(0)

  1. 暂无评论