var widths=1003;    /*显示高度*/                  
var heights=250;   /*显示宽度*/                   
var counts=3;              
img1=new Image ();img1.src='/images/banner01.jpg';
img2=new Image ();img2.src='/images/banner03.jpg';
img3=new Image ();img3.src='/images/banner02.jpg';url1=new Image ();url1.src='index.asp';
url2=new Image ();url2.src='index.asp';
url3=new Image ();url3.src='index.asp'; //
var nn=1;
var key=0;
function change_img(){
if(key==0){
key=1;
}else if(document.all){
document.getElementById("slidepic").filters[0].Apply();
document.getElementById("slidepic").filters[0].Play(duration=2);
}
eval('document.getElementById("slidepic").src=img'+nn+'.src');
eval('document.getElementById("slideurl").href=url'+nn+'.src');
for (var i=1;i<=counts;i++){
document.getElementById("slide"+i).className='slide';
}
document.getElementById("slide"+nn).className='slideover';
nn++;
if(nn>counts){nn=1;}
tt=setTimeout('change_img()',8000);
}//
function changeimg(n){nn=n;window.clearInterval(tt);change_img();}
document.write('<style type="text/css">');
document.write('.slide{border:#fff 1px solid; padding:1px; display:block; width:15px; height:15px; text-align:center;}');
document.write('a.slide{text-decoration:none;color:#888;font:9px sans-serif;background-color:#FC0; display:bolck; float:left;line-height:15px;}');
document.write('a.slide:hover{text-decoration:none;color:#888;font:9px sans-serif;border:1px solid #660099;line-height:15px;}');document.write('.slideover{border:#fff 1px solid; padding:1px; display:block; width:15px; height:15px; text-align:center;}');
document.write('a.slideover{text-decoration:none;color:#FFF;font:9px sans-serif;background-color:#333; display:bolck; float:left;font-weight:bold;line-height:20px;}');
document.write('a.slideover:{text-decoration:none;color:#fff;font:9px sans-serif;border:1px solid #660099;line-height:20px;}');
document.write('</style>');
document.write('<div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;">');
document.write('<div><a id="slideurl"><img id="slidepic" 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="width:100%;text-align:left;top:-25px;left:835px; display:none; position:relative;height:20px;border:0px;">');
for(var i=1;i<counts+1;i++){document.write('<a href="javascript:changeimg('+i+');" id="slide'+i+'" class="slide" style="margin-left:5px;" target="_self">'+i+'</a>');}
document.write('</div></div>');
change_img();

解决方案 »

  1.   

    var widths=1003;    /*显示高度*/                  
    var heights=250;  /*显示宽度*/                  
    var counts=3;              
    img1=new Image ();img1.src='/images/banner01.jpg'; 
    img2=new Image ();img2.src='/images/banner03.jpg'; 
    img3=new Image ();img3.src='/images/banner02.jpg'; 
    url1=new Image ();url1.src='index.asp'; 
    url2=new Image ();url2.src='index.asp'; 
    url3=new Image ();url3.src='index.asp'; // 
    var nn=1; 
    var key=0; 
    function change_img(){ 
    if(key==0){ 
    key=1; 
    }else if(document.all){ 
    document.getElementById("slidepic").filters[0].Apply(); 
    document.getElementById("slidepic").filters[0].Play(duration=2); 

    eval('document.getElementById("slidepic").src=img'+nn+'.src'); 
    eval('document.getElementById("slideurl").href=url'+nn+'.src'); 
    for (var i=1;i <=counts;i++){ 
    document.getElementById("slide"+i).className='slide'; 

    document.getElementById("slide"+nn).className='slideover'; 
    nn++; 
    if(nn>counts){nn=1;} 
    tt=setTimeout('change_img()',8000); 
    } // 
    function changeimg(n){nn=n;window.clearInterval(tt);change_img();} 
    document.write(' <style type="text/css">'); 
    document.write('.slide{border:#fff 1px solid; padding:1px; display:block; width:15px; height:15px; text-align:center;}'); 
    document.write('a.slide{text-decoration:none;color:#888;font:9px sans-serif;background-color:#FC0; display:bolck; float:left;line-height:15px;}'); 
    document.write('a.slide:hover{text-decoration:none;color:#888;font:9px sans-serif;border:1px solid #660099;line-height:15px;}'); document.write('.slideover{border:#fff 1px solid; padding:1px; display:block; width:15px; height:15px; text-align:center;}'); 
    document.write('a.slideover{text-decoration:none;color:#FFF;font:9px sans-serif;background-color:#333; display:bolck; float:left;font-weight:bold;line-height:20px;}'); 
    document.write('a.slideover:{text-decoration:none;color:#fff;font:9px sans-serif;border:1px solid #660099;line-height:20px;}'); 
    document.write(' </style>'); 
    document.write(' <div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;">'); 
    document.write(' <div> <a id="slideurl"> <img id="slidepic" 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="width:100%;text-align:left;top:-25px;left:835px; display:none; position:relative;height:20px;border:0px;">'); 
    for(var i=1;i <counts+1;i++){document.write(' <a href="javascript:changeimg('+i+');" id="slide'+i+'" class="slide" style="margin-left:5px;" target="_self">'+i+' </a>');} 
    document.write(' </div> </div>'); 
    change_img(); 
      

  2.   

    应该是用
    clearTimeout ( timeoutId );
    来实现吧