Forum Moderators: open

Message Too Old, No Replies

Load the background last

         

Hardbyte

11:24 am on Jul 19, 2004 (gmt 0)

10+ Year Member



Hi-ya,

Just wondering if there is a way to load the background last in a html/php file. Im also using css and janascript if any1 knows anything via those languages...

Cheers

jo1ene

11:05 pm on Jul 20, 2004 (gmt 0)

10+ Year Member



Most (newer) browsers load the background last by default.

tedster

11:57 pm on Jul 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's true that most modern browsers load backgrounds last, or very late - so much so that a commonly asked question is in the other direction: how to get the background to load sooner.

However, in your case I assume you want to be 100% sure that the background loads last. You could eliminate a regular body background declaration altogether - then add some javascript onLoad that declares a background image. However people with js turned off would get NO background at all ever.

In case you aren't concerned about non-js visitors, this might be one direction to try:

In the head:
<script type="text/javascript">
bgimg = new Image();
bgimg.src = "[url for your background image]";
</script>

In the body tag:
<body onload="document.body.background=bgimg.src;">

Using the same pre-loader script in the head, but a normal background declaration in the body, would pre-load the background-image and help it to display earlier in the rendering cycle.

Hardbyte

8:50 am on Jul 21, 2004 (gmt 0)

10+ Year Member



Cheers for that - much appreciated. Will give it a go.

Thanks again