Jump to content
Killersites Forums

Image gallery not working in IE(Please help me)


Recommended Posts

I am trying to create a Image slideshow(gallary) in javascript which works fine in all other browsers like opera, firefox, google chrome but it not works in any version of IE

 

 

//This code is saved in .js file

 

var slideimages=new Array()

function slideshowimages(){

for (i=0;i<slideshowimages.arguments.length;i++){

slideimages=new Image()

slideimages.src=slideshowimages.arguments

}

}

//configure the speed of the slideshow, in miliseconds

var slideshowspeed=4000

 

var whichimage=0

function slideit(){

if (!document.images)

return

document.images.slide.src=slideimages[whichimage].src

if (whichimage<slideimages.length-1)

whichimage++

else

whichimage=0

setTimeout("slideit()",slideshowspeed)

}

 

 

// This code is saved in .html file

 

<img src="images/qdimages/eth.jpg" name="slide" border=0 width="242px" height="190px">

<script>

slideshowimages("images/qdimages/eth1.jpg","images/qdimages/eth2.jpg","images/qdimages/jonica1.jpg","images/qdimages/jonica3.jpg","images/qdimages/jonica4.jpg","images/qdimages/jonica5.jpg")

slideit();

</script>

 

Please anyone help where i am doing wrong.

Link to post
Share on other sites

It's good practice to use semi-colon ( ; ) at end of each line in Javascript, also to use opening and closing brackets on if statements etc. Also it's good practice to use ID's when you're doing these things, instead of name, so you can more accurately target elements, and also it works consistently across different browsers. In your case, put an ID on the image:

 

<img id="slideshow" src="images/qdimages/eth.jpg" border=0 width="242px" height="190px">

Notice the id "slideshow" above

 

 

 

Also you should maybe use an "onload" event to fire the slideshowimages() and slideit() functions:

<script>
window.onload = function(){
slideshowimages("images/qdimages/eth1.jpg","images/qdimages/eth2.jpg","images/qdimages/jonica1.jpg","images/qdimages/jonica3.jpg","images/qdimages/jonica4.jpg","images/qdimages/jonica5.jpg");
slideit();
};
</script>

 

 

 

 

Here's the code that I've tested just now and confirm it's working on IE6 and FF3.6:

 

var slideimages = new Array();
var slideshowspeed = 4000;
var whichimage=0;
var t;

function slideshowimages(){
for (i=0;i<slideshowimages.arguments.length;i++){
	slideimages[i] = new Image();
	slideimages[i].src = slideshowimages.arguments[i];
}
}

function slideit(){
if(!document.getElementById("slideshow")){
	return;
}
document.getElementById("slideshow").src = slideimages[whichimage].src;

if(whichimage<slideimages.length-1){
	whichimage++;
}else{
	whichimage=0;
}
t = setTimeout(slideit, slideshowspeed);
}

 

:lol:

Edited by BeeDev
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...