I have managed to get a tating image working with the following javascript:
<script type="text/javascript">
(function() {
var rotator = document.getElementById('rotator');
var imageDir = '';
var delayInSeconds = 5;
var images = ['h-images/homepage.jpg', 'h-images/rentalspage.jpg', 'h-images/investpage.jpg'];
var num = 0;
var changeImage = function() {
var len = images.length;
rotator.src = imageDir + images[num++];
if (num == len) {
num = 0;
}
};
setInterval(changeImage, delayInSeconds * 1000);
})();
</script>
the page is www.helenmarino.com/test.html (you may have to refresh the page)
I am surprised I managed to get this far so any simple code added to make the images fade nicely would be greatly appreciated.
many thanks
Helen
Here's one that might work for you: http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
Thanks - this looks great.
Sorry but I am a real novice at javascript - only thing is the instructions are not that clear - I have opened the file - do I now save it in
the first head section of my html page?
Also I can't work out which bit I specify my images in? Or with the full version of the cycle how I determine it so I just have a fade option with the ability to scroll to next page?
Maybe this is beyond my limits? Are there any detailed notes on how to do this?
Thanks
Download the Cycle plug-in script and save it to your local site folder. I prefer to keep scripts in my Scripts folder but that's up to you.
http://jquery.malsup.com/cycle/download.html
jQuery has 3 basic parts to it:
<head>
<!-- jQuery latest core library -->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js">
</script>
<!-- Cycle plugin -->
<script type="text/javascript" src="Scripts/jquery.cycle.all.latest.js"></script>
</head>
<body>
<div class="slideshow">
<img src="image1.jpg" width="200" height="200" alt="description" />
<img src="image2.jpg" width="200" height="200" alt="description" />
<img src="image3.jpg" width="200" height="200" alt="description" />
<img src="image4.jpg" width="200" height="200" alt="description" />
</div>
<!--Cycle function code-->
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade'
});
});
</script>
</body>
That's all there is to it. If you want anything fancier, look at Cycle's More Demos & Examples near the bottom of their home page.
Nancy O.
Thanks - I have:
1) Put this in my head:
<head>
<!-- jQuery latest core library -->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js">
</script>
<!-- Cycle plugin -->
<script type="text/javascript" src="Scripts/jquery.cycle.all.latest.js"></script>
</head>
2. Put this in my body:
<div class="slideshow">
<img src="h-images/homepage.jpg'" width="600" height="298" alt="description" />
<img src="h-images/rentalspage.jpg'" width="200" height="298" alt="description" />
<img src="h-images/invest.jpg'" width="200" height="298" alt="description" />
</div>
<!--Cycle function code-->
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade'
});
});
</script>
3. Added the downloaded file and saved as a file in scripts folder.
You can now see the it on www.helenmarino.com/test.html (will need to refresh) - but I think I have gone wrong somewhere by not refering to where it should be on my html page? I want it where the current main image is.
Sorry for being such a pain - you have made this v easy to understand, I'm just missing what I should put where I actually want the image to go.
Many thanks - I will have another look now in the morning.
Helen
Everything looks fine except I don't see the jquery.cycle.js file on your remote server. Did you upload it?
404 Not found
<script type="text/javascript" src="Scripts/jquery.cycle.all.latest.js"></script>
Nancy O.
Hi Nancy
I started again from the start as I had not used a capital S for my scripts folder.
I saved the file under the Scripts folder as jquery.cycle.all.js
I then tried to uplaod it and got an error message:
file activity not incomplete. 1 file or folder(s) were not completed
Can you help please?
Thanks
Hi Nancy
I can upload all my html files okay - it just seems to be this js one. I tried loads of times.
I have just moved it to my main folder instead of the scripts folder and it uploaded okay.
Some success then - if you refresh the www.helenmarino.com/test.html page then the images do appear now - but not in a slideshow and in the wong place?
Any comments please?
Thanks
Helen
Boils down to a path/naming problem.
Change this in your page:
<!-- Cycle plugin -->
<script type="text/javascript" src="Scripts/jquery.cycle.all.latest.js"></script>
to this:
<!-- Cycle plugin -->
<script type="text/javascript" src="jquery.cycle.all.js"></script>
Nancy O.
From this page:
http://jquery.malsup.com/cycle/int2.html
<!--Cycle function code-->
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade',
speed: 800, //speed in milliseconds
timeout: 3000,
next: '.slideshow',
pause: 1
});
</script>
Nancy O.
North America
Europe, Middle East and Africa
Asia Pacific