Move this topic
Javascript slideshow - help!!!
in Getting Started
•
3 months ago
Ok, so I need a Javascript slideshow that will:
Do you know were I can find this?? Or how can I make it?
Thanks so mu!!ch
- display images in a random order
- allow me to add a link to each image, so when you click on it, it will direct you to a certain website (I need to add to each image a different link)
- allow me to set a certain time for each image to be displayed (ex: say I have 3 images: I want, for instance, the first image to be displayed for 10 seconds, the 2nd image for 5 seconds and the 3rd image for 25 seconds)
Do you know were I can find this?? Or how can I make it?
Thanks so mu!!ch
1
Replies(18)
Re: Javascript slideshow - help!!!
3 months ago
Re: Javascript slideshow - help!!!
3 months ago
Ok, so it works fine as it is, but if I try to add more pictures, it stops working :( any idea why?
Leave a comment on rminde's reply
Re: Javascript slideshow - help!!!
3 months ago
Ok, thanks a lot!!! I really, really appreciate it! :)
Leave a comment on irina793's reply
Re: Javascript slideshow - help!!!
3 months ago
please show us your script, do you have a link is it online?
Leave a comment on rminde's reply
Re: Javascript slideshow - help!!!
3 months ago
no, it's not online. But here's the script:
<style type="text/css">
ul li img{
position: absolute;
top: 370px;
left: 350px;
}
#info{
position: absolute;
left: 380px;
top: 780px;
}
</style>
<script type="text/javascript">
var actPic = randomBetween(0, 2);
$('ul li').css({display:"none"});
showPic();
function randomBetween(minVal,maxVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return Math.round(randVal);
}
function showPic(){
var nextPic = randomBetween(0, 2);
while(nextPic == actPic){
nextPic = randomBetween(0, 2);
}
var delay = parseInt($('ul li').eq(nextPic).find("img").attr("showtime"));
$('ul li').eq(actPic).fadeOut();
$('ul li').eq(nextPic).fadeIn("normal", function(){
actPic = nextPic;
setTimeout(showPic, delay);
$('#info').text("ShowTime: "+delay);
}); }
</script>
<ul>
<li><a
href="http://ro.linkedin.com/pub/carmen-virginia-chiru/2a/845/8b4"><img
src="1.jpg" showtime="10000" border="0"
height="300" width="400"></a></li>
<li><a href="https://twitter.com/#!/amillionseconds"><img
src="logo.jpg" showtime="5000" border="0"
height="300" width="400"></a></li>
<li><a
href="http://ro.linkedin.com/pub/luci-melinte/2a/bab/177"><img
src="2.jpg" showtime="10000" border="0"
height="300" width="400"></a></li>
</ul>
<div id="info"></div>
Leave a comment on irina793's reply
Re: Javascript slideshow - help!!!
3 months ago
Leave a comment on rminde's reply
Re: Javascript slideshow - help!!!
3 months ago
well, I can't add a 4th, 5th, 6th etc photo. It only works with 3 images and I need to be able to add several other images.
Leave a comment on irina793's reply
Re: Javascript slideshow - help!!!
3 months ago
when you change the numbers of images you have to change the possible value for actPic too
gives you a 0, 1 or 2
i created now another variable call maxPic
just have a look
http://jsfiddle.net/UNjxg/1/
- var nextPic = randomBetween(0, 2);
gives you a 0, 1 or 2
i created now another variable call maxPic
- var maxPic = $('ul li').length - 1;
- var nextPic = randomBetween(0, maxPic);
just have a look
http://jsfiddle.net/UNjxg/1/
Leave a comment on rminde's reply
Re: Javascript slideshow - help!!!
3 months ago
uh, I'm so sorry to bother your like this, but it still doesn't work :( I have added a 4th image and the slide show only shows this 4th image and doesn't do anything else.
Leave a comment on irina793's reply
Re: Javascript slideshow - help!!!
3 months ago
<style type="text/css">
ul li img{
position: absolute;
top: 370px;
left: 350px;
}
#info{
position: absolute;
left: 380px;
top: 780px;
}
</style>
<script type="text/javascript">
var maxPic = $('ul li').length - 1;
var actPic = randomBetween(0, maxPic);
$('ul li').css({display:"none"});
showPic();
function randomBetween(minVal,maxVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return Math.round(randVal);
}
function showPic(){
var nextPic = randomBetween(0, maxPic);
while(nextPic == actPic){
nextPic = randomBetween(0, macPic);
}
var delay = parseInt($('ul li').eq(nextPic).find("img").attr("showtime"));
$('ul li').eq(actPic).fadeOut();
$('ul li').eq(nextPic).fadeIn("normal", function(){
actPic = nextPic;
setTimeout(showPic, delay);
$('#info').text("ShowTime: "+delay);
}); }
</script>
<ul>
<li><a
href="http://ro.linkedin.com/pub/carmen-virginia-chiru/2a/845/8b4"><img
src="1.jpg" showtime="10000" border="0"
height="300" width="400"></a></li>
<li><a href="https://twitter.com/#%21/amillionseconds"><img
src="logo.jpg" showtime="5000" border="0"
height="300" width="400"></a></li>
<li><a
href="http://ro.linkedin.com/pub/luci-melinte/2a/bab/177"><img
src="2.jpg" showtime="10000" border="0"
height="300" width="400"></a></li>
<li><a href="http://facebook.com"><img
src="TITLUL%20FINAL.jpg" showtime="1000" border="0"
height="300" width="400"></a></li>
</ul>
<div id="info"></div>
ul li img{
position: absolute;
top: 370px;
left: 350px;
}
#info{
position: absolute;
left: 380px;
top: 780px;
}
</style>
<script type="text/javascript">
var maxPic = $('ul li').length - 1;
var actPic = randomBetween(0, maxPic);
$('ul li').css({display:"none"});
showPic();
function randomBetween(minVal,maxVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return Math.round(randVal);
}
function showPic(){
var nextPic = randomBetween(0, maxPic);
while(nextPic == actPic){
nextPic = randomBetween(0, macPic);
}
var delay = parseInt($('ul li').eq(nextPic).find("img").attr("showtime"));
$('ul li').eq(actPic).fadeOut();
$('ul li').eq(nextPic).fadeIn("normal", function(){
actPic = nextPic;
setTimeout(showPic, delay);
$('#info').text("ShowTime: "+delay);
}); }
</script>
<ul>
<li><a
href="http://ro.linkedin.com/pub/carmen-virginia-chiru/2a/845/8b4"><img
src="1.jpg" showtime="10000" border="0"
height="300" width="400"></a></li>
<li><a href="https://twitter.com/#%21/amillionseconds"><img
src="logo.jpg" showtime="5000" border="0"
height="300" width="400"></a></li>
<li><a
href="http://ro.linkedin.com/pub/luci-melinte/2a/bab/177"><img
src="2.jpg" showtime="10000" border="0"
height="300" width="400"></a></li>
<li><a href="http://facebook.com"><img
src="TITLUL%20FINAL.jpg" showtime="1000" border="0"
height="300" width="400"></a></li>
</ul>
<div id="info"></div>
Leave a comment on rminde's reply
Leave a comment on rminde's reply
Re: Javascript slideshow - help!!!
3 months ago
have you included jquery and the document.ready function?
Re: Javascript slideshow - help!!!
3 months ago
I added the jquery, but not the document.ready function. were do I add that?
Leave a comment on rminde's reply
Re: Javascript slideshow - help!!!
3 months ago
like this:
- <script type="text/javascript">
- $(document).ready(function() {
var maxPic = $('ul li').length - 1;
var actPic = randomBetween(0, maxPic);
$('ul li').css({display:"none"});
showPic();
function randomBetween(minVal,maxVal)
{
var randVal = minVal+(Math.random()*(maxVal-minVal));
return Math.round(randVal);
}
function showPic(){
var nextPic = randomBetween(0, maxPic);
while(nextPic == actPic){
nextPic = randomBetween(0, macPic);
}
var delay = parseInt($('ul li').eq(nextPic).find("img").attr("showtime"));
$('ul li').eq(actPic).fadeOut();
$('ul li').eq(nextPic).fadeIn("normal", function(){
actPic = nextPic;
setTimeout(showPic, delay);
$('#info').text("ShowTime: "+delay);
});
}
}) - </script>
Leave a comment on rminde's reply
Leave a comment on irina793's reply
Re: Javascript slideshow - help!!!
3 months ago
yeah, it's really not easy to give you the help you are looking for.
i don't know what you are doing!
when it still doesn't work you made an error cause it works definitly!
i made a version on my webspace, you can copy it and then it is your turn to look what's wrong.
good luck.
http://www.moosemash.de/irina793/
i don't know what you are doing!
when it still doesn't work you made an error cause it works definitly!
i made a version on my webspace, you can copy it and then it is your turn to look what's wrong.
good luck.
http://www.moosemash.de/irina793/
Leave a comment on rminde's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic
Reply to irina793's question
{"z8466749":[14737000003026616,14737000003032045,14737000003029282,14737000003033119,14737000003033123,14737000003033133,14737000003034299,14737000003037119,14737000003038139,14737000003038145],"z5845604":[14737000003028581,14737000003036025,14737000003033121,14737000003033125,14737000003033391,14737000003038083,14737000003039029,14737000003040027,14737000003044011]}
Statistics
- 18 Replies
- 438 Views
- 0 Followers



