[snip]
> Then have a function that gets the img with
> getElementById(),
Use the images collection instead. It should be quicker, it involves
typing and it's self-documenting. If you add a name attribute to the image
with the same value as the id, use of the images collection expands your
target audience to include older browsers, too.
[snip]
> (the picture dimensions have to be identical for this to work, as
> width/height isn't updated, I believe
If you set the width or height attributes explicitly, then yes, you'd
either have to update them along with the image, or make all of the images
the same size. If you don't set those attributes, the element will grow or
shrink to fit.
> though you could write a function that replaces the entire <img> tag)
Why? Is there some reason, of which I'm not aware, where
img.width = x; // and .height where x is a number in pixels
won't work?
> Personally I hate slide shows with too long intervals. As everyone has
> their own viewing rhythm, a "next" button might be a good idea.
I wrote a slide show script two days ago, but the code was ugly and I
couldn't be bothered to test it properly, so I deleted it. It was fairly
versatile. Perhaps I should re-write it.
Mike

Signature
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Joakim Braun - 30 Dec 2004 12:43 GMT
<snip>
> > though you could write a function that replaces the entire <img> tag)
>
[quoted text clipped - 3 lines]
>
> won't work?
If you start out with an <img> with height/width attributes, then want to
replace the src with an image with different height/width, and don't want to
hard code the dimensions, you could replace the entire node and have the
browser figure out height/width as for an <img> without height/width.
But on reflection, there is removeAttribute()/removeAttributeNode(). Or
perhaps you could simply set the <img> height/width to null?
Joakim Braun
Joakim Braun - 30 Dec 2004 12:46 GMT
> <snip>
>
[quoted text clipped - 13 lines]
> But on reflection, there is removeAttribute()/removeAttributeNode(). Or
> perhaps you could simply set the <img> height/width to null?
Or don't use height/width at all.
Joakim Braun
Michael Winter - 30 Dec 2004 13:24 GMT
[snip]
> Or don't use height/width at all.
That's what I implied:
"If you set the width or height attributes explicitly, then yes,
you'd [...] have to update them [...]"
In other words, if you leave the dimensions to be defined implicitly (by
the image itself), you wouldn't have to do anything. :)
Mike

Signature
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Oscar Monteiro - 30 Dec 2004 15:14 GMT
here is a solution for your ten images with 5 sec interval:
<script type="text/javascript">
var image1=new Image()
image1.src="1.gif"
var image2=new Image()
image2.src="2.gif"
var image3=new Image()
image3.src="3.gif"
var image4=new Image()
image4.src="4.gif"
var image5=new Image()
image5.src="5.gif"
var image6=new Image()
image6.src="6.gif"
var image7=new Image()
image7.src="7.gif"
var image8=new Image()
image8.src="8.gif"
var image9=new Image()
image9.src="9.gif"
var image10=new Image()
image10.src="10.gif"
</script>
</head>
<body>
<img src="1.gif" name="slide" >
<script type="text/javascript">
//variable that will increment through the images
var step=1
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
if (step<10)
step++
else
step=1
}
var lock=false
var run
function show(){
if(lock==true){
lock=false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("slideit()", 5000);
}
}
</script>
<body Onload=show()>
>> <snip>
>>
[quoted text clipped - 18 lines]
>
> Joakim Braun