How to Preload Background Image?
Hi,
May I know what code should be added to make the background image appear before everything else?
My site is located at http://projectcm.redcardhq.net
As can be seen, the background takes too long to load...
Thanks.
Visit projectcm.2ya.com for the complete Championship Manager guide.
Wil posted this at 17:54 — 20th January 2002.
They have: 601 posts
Joined: Nov 2001
Hm. It came through OK and right on que on my 28k modem at home . I don't see the need for you to do this to be honest.
The only way I know of doing this is to create an intro page before this one and preload the images in the background using javascript, so that the images are already stored in your browsers cache. You could make it an empty page, or just a simple page with some "loading..." text if you wished.
You can pre-load images using Javascript similar to the code below. The code is designed for multiple images, so there might be more overheads than needed. I hope this helps.
<script LANGUAGE="JavaScript">
<!--
function doPreload()
{
var my_images = new Array('/path/to/bg/image.gif');
preloadImages(my_images);
}
function preloadImages(my_images_array) {
for(loop = 0; loop < my_images_array.length; loop++)
{
var an_image = new Image();
an_image.src = my_images_array[loop];
}
}
// -->
</script>
<BODY OnLoad="doPreload();">
- wil
detox posted this at 01:05 — 21st January 2002.
They have: 571 posts
Joined: Feb 2001
There are a lot of good preloading scripts out there, just be sure that if you go down this way, that you at least keep there interest in you site whilst yo do so. If I have to wait a long time for a preloader and the site inside isn't worth the wait I just go away!
Give an introduction to the site so their attention is taken away from the preloader.....
Project CM posted this at 10:53 — 21st January 2002.
They have: 23 posts
Joined: Dec 2001
So you reckon it's better to leave it as it is? Was initially afraid it wouldn't turn up well on 28.8...but since it's ok, then I'll save the trouble...Thanks!
Visit projectcm.2ya.com for the complete Championship Manager guide.
Wil posted this at 11:18 — 21st January 2002.
They have: 601 posts
Joined: Nov 2001
I would leave it, yes. On my work machine (connected via a T3 line) it all loads in an instant and all looks OK.
But even on my 28k line at home it all loaded fairly quickly with the background image loading roughly the same time as the rest of the page. As there was enough content for me to read on the page, I didn't notice the background not loading or loading faster or slower than any other part of the page.
- wil
Project CM posted this at 14:13 — 21st January 2002.
They have: 23 posts
Joined: Dec 2001
Greatly appreciated...
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.