开发者

Preload a background image in Javascript - without declaring CSS beforehand

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜