Jump to content

[SOLVED] Problems with slideshow in IE6


Guardian-Mage

Recommended Posts

My slideshow code doesn't work on IE6

http://www.HillBillie4x4.com/buggie.php (Images are huge, please be patient)

 

Javascript

<script type="text/javascript">
<!--
<?php
if (isset($_POST['slide']))
{
$slide = $_POST['slide'];
echo "var curImg = $slide;";
}
else
{
echo "var curImg = 1;";
}
?>

var slideLength = 27;

var lock = false;
var run;

var idvar = 'p';

function changeImage(dir)
{
if (document.images)
     {
          curImg = curImg + dir;
	  
          if (curImg > slideLength)
          {
               curImg = 1;
          }
	  
          if (curImg < 1)
          {
               curImg = slideLength;
          }
	  
	  var id = "p" + curImg;	  
	  if (!document.getElementById(id))
	  {  
		curImg = curImg + dir;
	  }
	  var id = "p" + curImg;	  
	  var nextImage = document.getElementById(id).innerHTML;	
          document.getElementById('slideshow').innerHTML = nextImage;
          document.getElementById('slide').value = curImg;
     }
 else
 {
 	window.location = 'index.php';
 }
}
-->
</script>

Link to comment
Share on other sites

it looks like you're loading all of the images at once. If that is the case, it would be easier if you used some style attirbutes to show/hide the images

 

lets say you put them all in a div

<div id="img_container">

<img src="..." id="..." />

...

</div>

 

now from here i would do something a lil more advnaced, use an object to control the pics and their flow

 

put this script at the bottom of your page before the ending body tag:

 

var slideShow = {

   	imgs: '',
    cur_img: 0,
    
    start: function(){
        slideshow.imgs = document.getElementById('img_container').getElementsByTagName('img');
    },
    
    next: function(){
    	if((slideShow.cur_img + 1) >= slideShow.imgs.length){
        	slideShow.cur_img = 0;
        }else{
            slideShow.cur_img++;  
        }     
        slideShow.dispImg();
    },
    
    prev: function(){
    	if((slideShow.cur_img - 1) < 0){
        	slideShow.cur_img = slideShow.imgs.length - 1;
        }else{
            slideShow.cur_img--;  
        } 
        slideShow.dispImg();
    },
    
    dispImg: function(){
    	var count = slideShow.imgs.length;
        for(var i = 0; i < count; i++){
        	//set all of the images display to none except the current image
        	var visb = (i == slideShow.cur_img) ? 'block' : 'none';
            slideShow.imgs[i].style.display = visb;
        }
    },
    
    goToImg: function(go){
    	//i'll save this one for you
    }
};

slideShow.start();

 

and to use this is pretty simple

 

for your next and back buttons you just add the onclick="slideShow.next();" attribute to the buttons

 

you should set all of your images to display = none when the page loads except the first one, or whatever one you want to show

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.