View Full Version : Preload background img attached with CSS?

02-28-2004, 02:05 PM
Is it possible to preload a background image that is attached using CSS?
Dreamweaver doesn't give you the option to preload the image as it doesn't see it as being IN the page.

02-28-2004, 02:13 PM
You can always make your own preloader! CSS doesn't have the ability to do this.

var my_css_bg = new image;
my_css_bg.src = 'css_bg.gif';

That's all it requries ( I think ), I'm not a JS guru though .. if it's wrong I'm sure someone else will correct me. :)

02-28-2004, 03:50 PM
Originally posted by Mhtml
var my_css_bg = new Image;;)…

02-28-2004, 07:19 PM
S'cuse my ignorance but that goes where exactly?
Thanks for the reply.

02-28-2004, 09:04 PM
Best place would generally be the <head> section, but I suppose it could go anywhere.

02-28-2004, 09:38 PM
Inside <script type="text/javascript"> and </script>. (Note that application/x-javascript is technically more correct as 1) javascript isn't text and 2) I don't think text/javascript is a technically registered mime type but application/x-javascript is poorly supported).

02-29-2004, 01:36 AM
Thanks for the help.

I have found that what I was using did work (helluva complicated) on IE and Netscape FOR PC. But of course it doesn't behave like it should on IE5 for Mac which is what I'm working on :p .

Why oh why can't they just make all browsers and OS's compatable? Oh I know... 'cos then I might not sit here till 2.30am on a Saturday night fighting with it!