JavaScript预加载图像 [英] JavaScript Preloading Images
本文介绍了JavaScript预加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你能否告诉我,我在下面写的功能是否足以在大多数(如果不是所有)今天常用的浏览器中预装图像?
Can you tell me if the function I wrote below is enough to preload images in most if not all browsers commonly used today?
function preloadImage(url)
{
var img=new Image();
img.src=url;
}
我有一个imageURL数组,我循环并为每个调用preloadImage函数网址。
I have an array of imageURLs that I loop and call the preloadImage function for each URL.
推荐答案
是的。这适用于所有主流浏览器。
Yes. This should work on all major browsers.
这篇关于JavaScript预加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文