A jQuery Script Here is a simple jQuery script to preload the images.

(function($){var cache =[];// Arguments are image paths relative to the current page.
$.preLoadImages =function(){var args_len = arguments.length;for(var i = args_len; i--;){var cacheImage = document.createElement('img');
cacheImage.src = arguments[i];
cache.push(cacheImage);}}})(jQuery)

You'll notice that this isn't anything special to jQuery. You can change the name from $.preLoadImages() to some other function name and use this outside of jQuery.

To use the preloading make a call like:

jQuery.preLoadImages("image1.gif", "/path/to/image2.png");
posted @ 2014-04-17 16:50  新的方向  阅读(136)  评论(0编辑  收藏  举报