Fade in all images on load page
Permalink
Hi,
Here's something for you. I Got a client who wants all images to be fading in when the page loads. I think this should be possible with javascript?
I found a script wich does exactly what i want.
http://clagnut.com/sandbox/imagefades/...
But where should i put this script?
I'me not that great at javascript so who can help me out?
Here's something for you. I Got a client who wants all images to be fading in when the page loads. I think this should be possible with javascript?
I found a script wich does exactly what i want.
http://clagnut.com/sandbox/imagefades/...
But where should i put this script?
I'me not that great at javascript so who can help me out?
Tried it with this function:
But putted this just between the head codes.
Doesn't work... So what you're telling me is that when i put this in a javascript file and link it it wil work?
Or is my javascript just crap=P
<script type="text/javascript"> // fade in images already loaded: $('..ccm-image-block img').hide().load(function () { $(this).fadeIn(1000); }); </script>
But putted this just between the head codes.
Doesn't work... So what you're telling me is that when i put this in a javascript file and link it it wil work?
Or is my javascript just crap=P
Your javascript is just crap ;)
Not a bad start, though. Here's what you want to fix...
First of all, you only want a single period before "ccm-image-block" (you have two -- it should be '.ccm-image-block img', NOT '..ccm-image-block img').
Also, I think the .load() function doesn't do what you think it does (?) -- if you check the jquery documentation you'll see that it is meant for retrieving data on the server, not for loading an image. You already have the image loaded by virtue of it being in your html.
Finally, for various reasons having to do with the way different browsers load pages, it's best to put any code that you want to run on page load in jquery's $(document).ready() function (for more details seehttp://docs.jquery.com/Tutorials:Introducing_$(document).ready()... ).
So I think what you want is something like this:
Hope that helps!
-Jordan
Not a bad start, though. Here's what you want to fix...
First of all, you only want a single period before "ccm-image-block" (you have two -- it should be '.ccm-image-block img', NOT '..ccm-image-block img').
Also, I think the .load() function doesn't do what you think it does (?) -- if you check the jquery documentation you'll see that it is meant for retrieving data on the server, not for loading an image. You already have the image loaded by virtue of it being in your html.
Finally, for various reasons having to do with the way different browsers load pages, it's best to put any code that you want to run on page load in jquery's $(document).ready() function (for more details seehttp://docs.jquery.com/Tutorials:Introducing_$(document).ready()... ).
So I think what you want is something like this:
<script type="text/javascript"> // fade in images already loaded: $(document).ready(function() { $('.ccm-image-block img').hide().fadeIn(1000); }); </script>
Hope that helps!
-Jordan
Then, at the top of your theme's page templates, you want to add this code (inside the html <head> section):
<script type="text/javascript" src="<?php print $this->getThemePath(); ?>/imagefade.js"></script>
I can't tell you exactly where to put this because it goes in different places depending on how the theme is set up (but again, if you reply with the theme name I can probably respond back with the proper location).
Good luck!
-Jordan Lev