开发者

Preload a background image in Javascript - without declaring CSS beforehand

开发者 https://www.devze.com 2023-01-22 16:27 出处:网络
I already know how to preload an image with Image.onload. But what about preloading a style.background image?

I already know how to preload an image with Image.onload. But what about preloading a style.background image?

I need this f开发者_如何转开发or a game that's going to be preloading sprite sheets for different levels of a DHTML game.

I've had no success figuring out how to get style.background to use an Image object.

So how do I preload a style.background image, only with Javascript.


Just preload it the normal way.

The image will be cached in any case, regardless whether you use it as an img element, or as a background-image property.

0

精彩评论

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