SoFunction
Updated on 2025-03-09

js realizes the image slide switching effect that can be called multiple times on the same page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<title>js Image slide switching effect that can be called multiple times on the same page</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--Add the following code between <head> and </head>-->
<script language="javascript">
//Declare the namespace
var $o = new Object();
//Basic Method
$ = {
 e:function(a,f){
  for(var i=0,j=;i<j;i++){(a[i],i);}
 }
}
$o. slide = function (id,arg){
 var arg = arg||{},
  t = (id),
  a = ("a"),
  lis = [],
  cl = ||'#f30',
  ctm = *1000||2000,
  w = ,
  h = ,
  b = ['<ul style="margin:0; padding:0; list-style:none; display:block; position:absolute; bottom:10px; right:10px;">'],
  index = 0,
  $ = null,
  $ = null;
  function change(i){
   if(!!$){clearTimeout($);}
   index = !isNaN(i)?i:index+1;
   if(index >= ){index = 0;}
   $(lis,function(k){if(k == index){c(1,this);}else{c(0,this)}});
   var to = - index*h;
   if(a[0].offsetTop == to){
    return;
   }else{
    if(!!$){clearInterval($);}
    $ = setInterval(function(){
     var ot = a[0].offsetTop;
     v = Math[to<ot?'floor':'ceil']((to - ot)*0.2);
     if(ot == to){clearInterval($);$=null;st();}
     ot += v;
     a[0]. = ot + "px";
    },30)
   };
  }
  function c(b,o){
   = !!b?cl:"#fff";
   = !!b?"#fff":cl;
  }
  function st(){
   if(!!$)clearTimeout($);
   $ = setTimeout(function(){change()},ctm);
  }
  with(){overflow = 'hidden';position = 'relative';}
  $(a,function(n){
   = "block";
   with(){borderWidth = '0';width = w + 'px';height = h + 'px';}
   ('<li style="width:20px; height:20px; line-height:20px; display:block; float:left; margin-left:5px; border:1px solid ' + cl + '; background-color:#fff; color:' + cl +'; font-size:14px; text-align:center; cursor:pointer;">' + (n+1) + '</li>');
  });
  ('</ul>');
  += ("");
  lis = ("li");
  $(lis,function(n){
   if(n == index){c(1,this)}
   = function(){
    if(n!=index)change(n);
   }
  });
  st();
}
</script>
</head>
<body>
<!--Add the following code between <body> and </body>-->
<div style="width:402px;height:228px;">
 <a href="javascript:alert('1')"><img src="/images/"></a>
 <a href="javascript:alert('2')"><img src="/images/"></a>
 <a href="javascript:alert('3')"><img src="/images/"></a>
 <a href="javascript:alert('4')"><img src="/images/"></a>
 <a href="javascript:alert('5')"><img src="/images/"></a>
 <a href="javascript:alert('6')"><img src="/images/"></a>
 <a href="javascript:alert('7')"><img src="/images/"></a>
 <a href="javascript:alert('8')"><img src="/images/"></a>
 <a href="javascript:alert('9')"><img src="/images/"></a>
</div>
<script language="javascript">
new $("aa");
</script>
<br>
<div style="width:402px;height:228px;">
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
</div>
<script language="javascript">
new $("bb",{color:'#000',time:0.2});
</script>
<br>
<div style="width:402px;height:228px;">
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
 <a href="###"><img src="/images/"></a>
</div>
<script language="javascript">
new $("cc",{color:'green'});
</script>
</body>
</html>