一个简单的图片轮换器在IE6.0和搜狗浏览器上试都没有问题,但在IE8.0上试验却出现问题了,具体表现为图片能轮转,但是右下角的几个小数字标签不能变动轮转,点击选择其中一个标签也不能立即反应过来
<SCRIPT type="text/javascript">
var widths  =420;
var heights =180;
var counts  =3;
var times   = 4000;
img1=new Image ();img1.src="images/change1.jpg";
img2=new Image ();img2.src="images/change2.jpg";
img3=new Image ();img3.src="images/change3.jpg";
url1=new Image ();url1.src='#';
url2=new Image ();url2.src='#';
url3=new Image ();url3.src='#';
var nn=1;
var key=0;
function change_img(){
 if(key==0){
  key=1;
 }else if(document.all){
  document.getElementById("pic").filters[0].Apply();
  document.getElementById("pic").filters[0].Play(duration=2);
 }
 eval('document.getElementById("pic").src=img'+nn+'.src');
 eval('document.getElementById("url").href=url'+nn+'.src');
 for (var i=1;i<=counts;i++){
  document.getElementById("xxjdjj"+i).className='axx';
 }
 document.getElementById("xxjdjj"+nn).className='bxx';
 nn++;
 if(nn>counts){nn=1;}
 tt=setTimeout('change_img()',4000);
}
function changeimg(n){
 nn=n;
 window.clearInterval(tt);
 change_img();
}
document.write('<style>');
document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}');
document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}');
document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
document.write('</style>');
document.write('<div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;">');
document.write('<div><a id="url" target="_blank"><img id="pic" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /></a></div>');
document.write('<div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;">');
for(var i=1;i<counts+1;i++){
 document.write('<a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self">'+i+'</a>');
}
document.write('</div></div>');
change_img();
</SCRIPT>

解决方案 »

  1.   

    我测试的 没问题,你看看页面引用的什么标准,我的是
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    用<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    也么得问题,图片用的你的头像<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
     </HEAD> <BODY>
      <SCRIPT type="text/javascript">
    var widths  =420;
    var heights =180;
    var counts  =3;
    var times   = 4000;
    img1=new Image ();img1.src="http://avatar.profile.csdn.net/A/4/1/2_webeidolon.jpg";
    img2=new Image ();img2.src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif";
    img3=new Image ();img3.src="http://avatar.profile.csdn.net/A/4/1/2_webeidolon.jpg";
    url1=new Image ();url1.src='#';
    url2=new Image ();url2.src='#';
    url3=new Image ();url3.src='#';
    var nn=1;
    var key=0;
    function change_img(){
     if(key==0){
      key=1;
     }else if(document.all){
      document.getElementById("pic").filters[0].Apply();
      document.getElementById("pic").filters[0].Play(duration=2);
     }
     eval('document.getElementById("pic").src=img'+nn+'.src');
     eval('document.getElementById("url").href=url'+nn+'.src');
     for (var i=1;i<=counts;i++){
      document.getElementById("xxjdjj"+i).className='axx';
     }
     document.getElementById("xxjdjj"+nn).className='bxx';
     nn++;
     if(nn>counts){nn=1;}
     tt=setTimeout('change_img()',4000);
    }
    function changeimg(n){
     nn=n;
     window.clearInterval(tt);
     change_img();
    }
    document.write('<style>');
    document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}');
    document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}');
    document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}');
    document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}');
    document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
    document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
    document.write('</style>');
    document.write('<div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;">');
    document.write('<div><a id="url" target="_blank"><img id="pic" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /></a></div>');
    document.write('<div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;">');
    for(var i=1;i<counts+1;i++){
     document.write('<a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self">'+i+'</a>');
    }
    document.write('</div></div>');
    change_img();
    </SCRIPT>
     </BODY>
    </HTML>
      

  2.   

    我这里用IE8看着也没问题.是不是楼主的IE8安全设置过高了.
      

  3.   

    换个docType看看,doctype也会影响css、js的;