...

View Full Version : Could someone please tell me what is wrong with this code???



Halcyon1967
12-25-2011, 10:30 PM
Could someone please tell me why this doesn't work???
<html>
<head>
<title>slideshow</title>
</head>
<body>
<script type="text/javascript">
theimage = new Array();
// The dimensions of ALL the images should be the same or some of them may look stretched or reduced in Netscape 4.
// Format: theimage[...]=[image URL, link URL, name/description]
theimage[0]=["http://img844.imageshack.us/img844/981/img3small.jpg", length="380", width="380"];
theimage[1]=["http://img850.imageshack.us/img850/4371/img2small.gif", length="380", width="380"];
theimage[2]=["http://img191.imageshack.us/img191/2923/img1small.gif", length="380", width="380"];
///// Plugin variables
playspeed=3000;// The playspeed determines the delay for the "Play" button in ms
dotrans=1; // if value = 1 then there are transitions played in IE
transtype='blendTrans';// 'blendTrans' or 'revealtrans'
transattributes='23';// duration=seconds,transition=#<24
//#####
//key that holds where in the array currently are
i=0;
//###########################################
window.onload=function(){
//preload images into browser
preloadSlide();
//set transitions
GetTrans();
//set the first slide
SetSlide(0);
//autoplay
PlaySlide();
}
//###########################################
function SetSlide(num) {
//too big
i=num%theimage.length;
//too small
if(i<0)i=theimage.length-1;
//switch the image
if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Apply()')
document.images.imgslide.src=theimage[i][0];
if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Play()')
}
//###########################################
function PlaySlide() {
if (!window.playing) {
PlayingSlide(i+1);
if(document.slideshow.play){
document.slideshow.play.value=" Stop ";
}
}
else {
playing=clearTimeout(playing);
if(document.slideshow.play){
document.slideshow.play.value=" Play ";
}
}
// if you have to change the image for the "playing" slide
if(document.images.imgPlay){
setTimeout('document.images.imgPlay.src="'+imgStop+'"',1);
imgStop=document.images.imgPlay.src
}
}
//###########################################
function PlayingSlide(num) {
playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed);
}
//###########################################
//desc: picks the transition to apply to the images
function GetTrans() {
//si=document.slideshow.trans.selectedIndex;
if((document.slideshow.trans && document.slideshow.trans.selectedIndex == 0) || (!document.slideshow.trans && dotrans==0)){
dotrans=0;
}
else if ((document.slideshow.trans && document.slideshow.trans.selectedIndex == 1) || (!document.slideshow.trans && transtype == 'blendTrans')){
dotrans=1;
transtype='blendTrans';
document.imgslide.style.filter = "blendTrans(duration=1,transition=1)";
}else{
dotrans=1;
transtype='revealtrans';
if(document.slideshow.trans) transattributes=document.slideshow.trans[document.slideshow.trans.selectedIndex].value;
document.imgslide.style.filter = "revealTrans(duration=1,transition=" +transattributes+ ")";
}
}
//###########################################
function preloadSlide() {
for(k=0;k<theimage.length;k++) {
theimage[k][0]=new Image().src=theimage[k][0];
}
}
</script>
<form name="slideshow">
<table style="width: 502px; height: 358px;" border="1"
cellpadding="2" cellspacing="0">
<tbody>
<tr>
<td align="center">
<a href="#"
onmouseover="this.href=theimage[i][1];return false">
<script type="text/javascript">
document.write('<img name="imgslide" id="imgslide" src="'+theimage[0][0]+'" border="0">')
</script></a></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

Old Pedant
12-25-2011, 10:37 PM
In what way does it not work?

You do know, I hope, that style.filter is strictly an MSIE-ism? It won't do anything at all in other browsers.

There are other, much much better, slide shows out there with transition effects that work in all modern browsers. That code looks like a refugee from about year 2000.

Halcyon1967
12-25-2011, 10:45 PM
I'm using Kompozer and when I test it all I'm getting is a box with no pictures. Could you help me out with a good slideshow? I just want a faded transition.

Halcyon1967
12-25-2011, 10:55 PM
OK it does work I was just doing it wrong. Could you still help me out with a slideshow?

Philip M
12-26-2011, 09:23 AM
OK it does work I was just doing it wrong. Could you still help me out with a slideshow?

See Old Pedant's advice in Post #2.

Old Pedant
12-27-2011, 02:26 AM
One that I just started working with that I like is here:
http://www.twospy.com/galleriffic/

But it's a bit of overkill for a 3-image slideshow if that's really all you have.

Halcyon1967
12-27-2011, 01:29 PM
Ok thanks. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum