Welcome visitor
* Login
* Register
It is currently January 18th, 2019, 7:35 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  How can I preload images?
PostPosted: November 14th, 2009, 5:47 am 

Posts: 39
You know the problem that is to wait or make the user wait to load high resolution pictures, so I'm looking for a way to preload them, do you know how to do it?


Top
 Profile  
 
  Re: How can I preload images?
PostPosted: November 17th, 2009, 2:59 am 
User avatar

Posts: 79
<script type="text/javascript">
    if (document.images) //This line checks if the document.images object exist (coz' older browsers wont support it)
    {
      preload_images = new Image();
      img = new Array();
      img[0] = "highres01.jpg";
      img[1] = "highres02.jpg";
      img[2] = "highres03.jpg";
      var i = 0;
      for(i=0; i<pics.length; i++) 
         {preload_images.src = img[i];}
    }
</script>

and to call each image do it as you would usually do, for example:
<img id="img1" />


Bonus (to change a pic "on the fly"):
<span onmouseover="document.getElementById('img1').src='highres01.jpg';">
change pic1</span>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron