Forum Moderators: open
Head code
<script LANGUAGE="JavaScript">
<!-- Begin
NewImg = new Array (
"images/Landscape.jpg",
"images/Portrait.jpg",
);
var ImgNum = 0;
var ImgLength = NewImg.length - 1;
var delay = 6000;
var lock = false;
var run = setInterval("chgImg(1)", delay);
var lock = true;
function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg[ImgNum];
}
}
function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval("chgImg(1)", delay);
}
}
</script>
Body code
<img border="0" src="images/Landscape.jpg" name="slideshow">
Please, any help would be appreciated...
For example, in a different scenario, you have a link to "preview selected image" next to a select list of images. The select list has options like this:
<option value="some-image.jpg:300:400">some-image.jpg</option>
OnClick of the preview link, JS would get the value of the selected option, split on the colons, and assign the width and height to the target display image.
First you need to start using id to reference your images instead of name.
<img border="0" src="images/Landscape.jpg" name="slideshow" id="slideshow">
Then I'm not sure where you'll add this, but pass the width, height, url, and id to the function that assigns the images to the object.
function swapImg(id,url,w,h) {
var obj = document.getElementById(id);
if (obj) {
obj.width=w;
obj.height=h;
obj.src=url;
}
function chgImg(direction)
Is your
function swapImg(id,url,w,h)
effectively the same as my
function chgImg(direction)
to which I just add the id,url,w,h - thus making it
function chgImg(direction,id,url,w,h)
and if so where do I then add
var obj = document.getElementById(id) etc.
or can I then include all the elements in the initial array separating each by a comma?
And given my array of images will be more than the 2 I've used in the example code of the first post and may have say 12 images in it and there may be multiple changes from landscape to portrait to landscape to portrait etc how do I then list all these w and h permutations?
I know its more questions than answers so far but I will continue to appreciate all the help coming my way...
The other factor I should have mentioned - this is only a problem with the live website. The mirror site I have on my hard-drive where I normally do all my changes and testing before publishing does not reproduce this problem. My host server is switched on to operate in a Microsoft Frontpage Server Extensions environment. So when I publish the version on my host server it has incorporated into the code a fixed width and height that I avoided putting in my side. When I delete this code and resave it in the live environment the problem doesn't go away and the code miraculously reappears when I next look. So, something that I can't see is taking image information and applying it to the slideshow image display area and reincorporating it into the code. Is this normal? And I presume I just have to live with that and find a solution that works in the live environment anyway!