"dave" wrote in message news:ec**************@tk2msftngp13.phx.gbl...
: I'm not sure..
: I need sth like when you hit page and image is available in cache it shuld
: display from cache rather than downloading from web server...
: i m displaying 50 phone images on page...so each time its downloading from
: web server...and takes bit long...
: i dont know abt preloading images into cache...
: just wanna know whats the best way to do it..
Ok, well you can wrap it in server-side script but I think this is
considered a client-side issue.
The way I understand it is when a page loads, the browser will render
elements that display on screen. So, if you have images, they will load one
at a time and if the user is on a dialup, they may see the image being drawn
as it is loaded. Obviously a high speed connection this is less noticeable.
When you reload a page that has already downloaded these images, they all
appear to load at once or "blink" on as people call it. The reason for this
is because the file is stored locally on the user's system in cache which
MSFT calls Temporary Internet Files. To get this same effect every time,
developers have figured out a way to preload the images before they appear
so when called for them on the page, they appear immediately.
I have a pretty elaborate preload routine but it can be as simple as this:
<script type="text/javascript">
// preload images into cache
if(document.images) {
var img1 = new Image();
img1.src = '/images/image1.jpg';
var img2 = new Image();
img2.src = '/images/image2.jpg';
}
function showImages() {
// display images on screen
document.getElementById('img1').src=img1.src;
document.getElementById('img2').src=img2.src;
}
</script>
</head>
<body onload="showImages()">
<img id="img1" src="" /><br />
<img id="img2" src="" /><br />
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp