interesting read. he didn't actually use AJAX to preload any type of image though, so why did he include that as a method?
1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.
Obviously images can be pre-loaded without JS using <img> with 0-width/height or css backgrounds, but in cases where the display of the pre-loaded images is script-dependent, then the preloading may as well be done by a script routine, ensuring that it's not done if script isn't supported.
I'm sure you've seen countless examples using the Image() object. Don't make the classic error of applying multiple filenames to the same instance of an Image object, using a loop.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
Well, I tried the first JS only example in the link 'Wolfshade' provided,
but now I have more questions that before...
Code:
<div class="hidden">
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var images = new Array()
function preload() {
for (i = 0; i < preload.arguments.length; i++) {
images[i] = new Image()
images[i].src = preload.arguments[i]
}
}
preload(
"http://domain.tld/gallery/image-001.jpg",
"http://domain.tld/gallery/image-002.jpg",
"http://domain.tld/gallery/image-003.jpg"
)
//--><!]]>
</script>
</div>
I changed the preload() array elements to valid images
The problem seems to be that there are TWO objects named preload()!!!
The first object is a function that should create the image elements.
The second object is 'preload( files )' and appears to be an array of files to be displayed (changed to valid links).
How can this be???
I also added 3 <img...> elements in the <body> because nothing seemed to display, but that did nothing either.
How would I reference the <img...> tags? Would I need to hard-code the <img> tags?
Or could they be generated dynamically to match the number of elements of the 'images' array?
Bottom line is that I think I don't understand what I'm doing at this point in time!
I changed the preload() array elements to valid images
The problem seems to be that there are TWO objects named preload()!!!
The first is a function, the second is a call to that function.
I also added 3 <img...> elements in the <body> because nothing seemed to display, but that did nothing either.
How would I reference the <img...> tags? Would I need to hard-code the <img> tags?
This code isn't about displaying images, it's about having them downloaded and in memory, ready to be displayed when their filename is specified by a script.
I thought you knew all this of old.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
The first is a function, the second is a call to that function.
This code isn't about displaying images, it's about having them downloaded and in memory, ready to be displayed when their filename is specified by a script.
I thought you knew all this of old.
That was the concept problem I was talking about in the 1st post.
I think it is beginning to gel.
Bookmarks