![]() |
Timebased event
Hi.
I have a header image I want to switch between several images by calling a PHP-script. Currently I have it changing image when clicking on the header-element(just to test that it actually works). HTML Code:
<?php echo link_js('static/js/HeaderChanger.js'); ?>javascript Code:
php Code:
This works great, it changes header when I click on it. However I want this to be timebased and not clickbased. I want it to change automatically every x seconds. Also it would be cool to have it transitioned like the first image is faded out, and the new one is faded in. How would I do that? I'm using jQuery btw. |
1 Attachment(s)
javascript Code:
I'm giving credit to ETbyrne for his jQuery Timer Plugin. Just change the "2000"(ms) to how ever long you want the delay to last. Attached you will find the zip file that contains the entire plugin distribution. VirusTotal Scan |
Thanks, that worked quite well.
However, it doesn't work exactly how I want it to. You see, that only changes the header once. I want it to change every x seconds. I tried to make a hack for it like this: javascript Code:
however that only seems to work twice because it changes 2 times after the page loaded. Then it doesn't change anymore.. Any ideas? |
Add myfunction() after you load the new image:
Code:
$(document).ready(function() {Btw how do you do the javascript code coloring? |
Did like this actually, but your point worked.
javascript Code:
Oh, and you use highlight=javascript but in [] and then /highlight within []. Now I'm just wondering how to do a fading transition between the images when it's loading a new image? |
To do fading would require that you somehow load the image into a hidden element which would then gradually appear over the old image. When the new image is then in place remove the element containing the old image.
|
Quote:
|
That would definitely be less technical, but the effect would probably be less crisp.
|
| All times are GMT. The time now is 02:53 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0