Javascript 这个jQuery幻灯片在IE 8中不起作用?有没有办法解决这个问题?

Javascript 这个jQuery幻灯片在IE 8中不起作用?有没有办法解决这个问题?,javascript,jquery,slideshow,Javascript,Jquery,Slideshow,注意:这不是我的脚本,它来自John Rausch的网站 更新: 哎呀,我没想到它会这样格式化!让我再发一个链接到他的网站。不想让任何人眼睛疲劳这对我在IE中很有用。不知道这是不是最好的幻灯片 我会将对象属性名和值放在引号中,以避免任何可能的变量名冲突。所以我会 <script type="text/javascript"> $(document).ready(function() { //Execute the slideShow, set 4 sec

注意:这不是我的脚本,它来自John Rausch的网站

更新: 哎呀,我没想到它会这样格式化!让我再发一个链接到他的网站。不想让任何人眼睛疲劳

这对我在IE中很有用。不知道这是不是最好的幻灯片

我会将对象属性名和值放在引号中,以避免任何可能的变量名冲突。所以我会

<script type="text/javascript">

$(document).ready(function() {  

 //Execute the slideShow, set 4 seconds for each images
 slideShow(2000);

});

function slideShow(speed) {


 //append a LI item to the UL list for displaying caption
 $('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');

 //Set the opacity of all images to 0
 $('ul.slideshow li').css({opacity: 0.0});

 //Get the first image and display it (set it to full opacity)
 $('ul.slideshow li:first').css({opacity: 1.0});

 //Get the caption of the first image from REL attribute and display it
 $('#slideshow-caption h3').html($('ul.slideshow a:first').find('img').attr('title'));
 $('#slideshow-caption p').html($('ul.slideshow a:first').find('img').attr('alt'));

 //Display the caption
 $('#slideshow-caption').css({opacity: 0.7, bottom:0});

 //Call the gallery function to run the slideshow 
 var timer = setInterval('gallery()',speed);

 //pause the slideshow on mouse over
 $('ul.slideshow').hover(
  function () {
   clearInterval(timer); 
  },  
  function () {
   timer = setInterval('gallery()',speed);   
  }
 );

}

function gallery() {


 //if no IMGs have the show class, grab the first image
 var current = ($('ul.slideshow li.show')?  $('ul.slideshow li.show') : $('#ul.slideshow li:first'));

 //Get next image, if it reached the end of the slideshow, rotate it back to the first image
 var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));

 //Get next image caption
 var title = next.find('img').attr('title'); 
 var desc = next.find('img').attr('alt'); 

 //Set the fade in effect for the next image, show class has higher z-index
 next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);

 //Hide the caption first, and then set and display the caption
 $('#slideshow-caption').slideToggle(300, function () { 
  $('#slideshow-caption h3').html(title); 
  $('#slideshow-caption p').html(desc); 
  $('#slideshow-caption').slideToggle(500); 
 });  

 //Hide the current image
 current.animate({opacity: 0.0}, 1000).removeClass('show');

}
</script>
而不是…{opacity:0.0},1000

另外,不要使用eval设置超时,只需使用函数引用或匿名函数即可。所以我会写:

current.animate({"opacity": "0.0"}, 1000).removeClass('show');
而不是。。。设置间隔“画廊”,速度


不确定你的CSS定位是什么样子的,但这张幻灯片看起来很棘手。

ie是个难题。为什么不试试ie标签呢


它在CSS上对我有效,当然它可以在JS上使用。

到目前为止,你试图解决什么问题?有错误吗?我认为如果你这样问你的问题,你不会得到答案。你什么意思不起作用?IE8中发生了什么?在其他浏览器中会发生什么?我首先要将对象属性名和值放在引号中,以避免变量名冲突。IE在这方面往往比其他浏览器更敏感。到底是什么不起作用?你可能想添加一些关于这个问题的更多信息,我可以看到IE有一个覆盖修复。修复IE8的东西可能是一个头痛的问题,我建议找到一个与IE兼容的幻灯片。你也可以使用元标记在IE7兼容视图中呈现它,根据开发人员的网站,它应该在其中工作;其他图像从未出现。
var timer = setInterval(gallery,speed);