I have a web page that uses a large image for its background. I was hoping to use jQuery to load the image once it is downloaded (basically the way that bing.com loads its background image). Is this possible with jQuery? If so, is there a plugin that you would recommend?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
You can go with the following trick, sorry if its a bit dirty.
Script :
Markup :
css:
hope this helps
A little sample on : http://xgreen.co.uk/test.htm
You can't use CSS background images, because it's impossible to attach an event to the loading of the images (as far as I know).
So I'll give it a shot, but haven't tested it:
HTML:
CSS:
Javascript:
This article may be useful. Copying from there:
HTML
CSS
Javascript
You could first load the image, and then, when it has finished loading, set it as background-image. That way the browser will (hopefully) load the background image from the cache instead of redownloading it. As you requested it as a plugin:
Use it like this: