Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #13512
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Preloading PNGs & assigning as bkgd-image |
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
| References | <f8s5p7dci7llr8kc70odlcq42fjilmbed4@4ax.com> |
| Message-ID | <XnsA03CD5090445Eeejj99@194.109.133.133> (permalink) |
| Date | 2012-04-21 18:56 +0000 |
Puzzled wrote on 21 apr 2012 in comp.lang.javascript:
> I'm trying to do pre-loading of images to reduce later latency,
> but am not getting anywhere despite everything I can find on the
> web and in Goodman. I'd very much appreciate some help! (Firefox
> 3.6.25 under XPProSP3).
>
> Supposedly, this should create an image object in the document's
> cache and load the bits into it:
>
> var foo = new Image(70,25) ;
> foo.src = 'mumble/fratz.png' ;
> foo.name = 'fratz' ;
>
> but console.log('image count',document.images) returns the empty
> array and ~.length) returns 0, suggesting that I didn't get the
> syntax right after all. Or that Image() isn't working, even
> though Firebug doesn't complain .
>
> To assign the image, if the preload were working, what syntax
> would I use?
>
> document.getElementById('some_td_id').style.background-image =
> foo.src ;
Do you want to substract mathematically
the value of image from the value of ...style.background?
Try:
document.getElementById('some_td_id').style.backgroundImage =
Reading the docs of css use in javascript has it's merits:
<http://www.w3schools.com/cssref/pr_background-image.asp>
> document.getElemnetById('some_td_id'_).style.background-image =
> document.images.fratz ;
no not this one.
> or something else?
<img src='mumble/fratz.png' style='width:1px;visibility:hidden;'>
document.getElementById('some_td_id').style.background-image =
'url(mumble/fratz.png)';
If you use an image twice on a page it is loaded only once, methinks.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Preloading PNGs & assigning as bkgd-image Puzzled <scratching.head@example.com> - 2012-04-21 14:20 -0400
Re: Preloading PNGs & assigning as bkgd-image Stefan Weiss <krewecherl@gmail.com> - 2012-04-21 20:50 +0200
Re: Preloading PNGs & assigning as bkgd-image Puzzled <scratching.head@example.com> - 2012-04-22 06:12 -0400
Re: Preloading PNGs & assigning as bkgd-image Stefan Weiss <krewecherl@gmail.com> - 2012-04-22 20:18 +0200
Re: Preloading PNGs & assigning as bkgd-image "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-21 18:56 +0000
Re: Preloading PNGs & assigning as bkgd-image Puzzled <scratching.head@example.com> - 2012-04-22 07:07 -0400
Re: Preloading PNGs & assigning as bkgd-image "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-04-23 10:22 +0000
Re: Preloading PNGs & assigning as bkgd-image Stefan Weiss <krewecherl@gmail.com> - 2012-04-23 20:46 +0200
Re: Preloading PNGs & assigning as bkgd-image Puzzled <scratching.head@example.com> - 2012-04-24 08:42 -0400
Re: Preloading PNGs & assigning as bkgd-image SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-04-22 00:24 +0200
csiph-web