开发者

Delay external javascript load by seconds

I have ONE external JavaScript file containing jQuery, Cufon, fonts, and the replace functions. I need this file to be loaded twice once on page load and again 3 seconds after page load. Is this possib开发者_JAVA技巧le?


Don't load it twice. Wrap what you have in it into a function, then call the function once when it loads, and once more after three seconds. For example, you might have something like this in your JavaScript file:

doSomeProcessing();
doSomeMoreProcessing();

Change it like this:

function myJavaScriptFile() {
  doSomeProcessing();
  doSomeMoreProcessing();
}
setTimeout(myJavaScriptFile, 3000);
myJavaScriptFile();


I don't think you need to load it twice. How about the following?

setTimeout(function(){Cufon.refresh();},3000);

disclaimer: I know nothing about Cufon and gleaned my knowlege from here


setTimeout(jQuery.getScript( url, [ success(data, textStatus) ] )),3000);

http://api.jquery.com/jQuery.getScript/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜