• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Preloading images ??

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I heard somewhere that it is possible to preload images in JScript, I now wonder if there is someone that know how to do this? or maybe know a site where I can read about it?
Catarina.
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's been a long time. But I think you can use the Image objects. i.e.
imgOn = new Image("ButtonOn.gif");
imgOff = new Image("ButtonOff.gif");
That might be right, I don't remember...


------------------
David Roberts, SCJP2
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Browsers generally cache images, so if you know you are going to need some images on later pages, then it is quite feasible to load them "invisbly" on the current page, using a simple <img src="/wherever/images/a.gif" width=1 height=1> anywhere on the page
This won't get in the way of someone reading the text on the page, but willl cache the image in the background. It is always advisable to use a full path to the images if you do this, just in case the browser caches /wherever/pages/../images/a.gif differently than /wherever/other/../images/a.gif (which it might).
This system has a few advantages over the Javascript version above:
1. It doesn't need Javascript, so it will work in browsers which don't support JavaScript, or which have Javascript disabled.
2. If the user has turned of images (or is using a text-only browser), then there is no overhead of loading images which won't ever be shown.
I hope this helps.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic