Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Best way to preload images
Old 11-26-2009, 06:32 PM Best way to preload images
World's Avatar
Extreme Talker

Posts: 202
Location: Santa Monica, CA
Trades: 0
I have 24 images in my gallery, and even though I have preloading code, it doesn't work.

I want that all 24 images preload in the background, so when a user clicks a thumbnail, the image is available right away.

Currently, it only downloads when the user clicks on the thumbnail.

I have read of jQuery preloading plug-ins. They look complicated and I have no idea how to implement it into my code.

Can you help me with this problem?
World is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-27-2009, 07:19 AM Re: Best way to preload images
Super Talker

Posts: 139
Name: John Davis
Trades: 0
you can declare your images in invisible (display: none) div.
Code:
<div style="display: none">
<img ...>
<img ...>
...
<img ...>
</div>
Then show images as usual you've did.
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
Reply With Quote
View Public Profile Visit MapMaster's homepage!
 
Old 11-27-2009, 08:02 AM Re: Best way to preload images
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Declare them as backgrounds to elements in the style sheet, then switch the className with the onclick event.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-27-2009, 10:26 AM Re: Best way to preload images
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
Originally Posted by World View Post
I have read of jQuery preloading plug-ins. They look complicated and I have no idea how to implement it into my code.
Not that I am aware of, and if there is, it is for fulfilling some more advanced purpose, not just simple preloading.

To preload an image in jQuery, all you need to do is this:
Code:
$('<img>').attr('src', 'path/to/image.jpg');
In regular JavaScript, this is expressed as:
Code:
document.createElement('img').src = 'path/to/image.jpg';
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-03-2009, 10:02 AM Re: Best way to preload images
freezea's Avatar
Experienced Talker

Posts: 45
Trades: 0
<!-- TWO STEPS TO INSTALL PRELOAD IMAGES:
1. Copy the coding into the HEAD of your HTML document
2. You can use the preload script with the "Change Image" script at
http://miscellaneous.javascriptsourc...nge-image.html -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
image1 = new Image();
image1.src = "image1.gif";
image2 = new Image();
image2.src = "image2.gif";
// End -->
</script>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 0.54 KB -->
__________________

Please login or register to view this content. Registration is FREE
: Web-based Excel-like Java reporting tool.
freezea is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Best way to preload images
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21530 seconds with 12 queries