<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>    <script src="jquery-1.4.1-vsdoc.js" type="text/javascript"></script>    <script type="text/javascript">
        var divindex=1;
       
        function dianji(id){
        document.getElementById(id).style.right="300px";
             document.getElementById(id).style.zIndex=divindex+1;
             divindex=divindex+1;
             
             var d=0;
              
       bw1= self.setInterval(fangfa(id,d),1);
             
             
         }
        function fangfa(id,d){
             
            var a=document.getElementById(id).style.left;
            a=a.substr(0,a.length-2);
            
            var b = (a*1)+1;
              
            document.getElementById(id).style.left=b+"px";
            
            if(d>300){
               
              self.clearInterval(bw1); 
            }
            d++;
           alert(d);
           
        }
    </script></head>
<body>
    <form id="form1" runat="server">
    <div onclick="dianji('div1')">
        div1
    </div>
    <div onclick="dianji('div2')">
        div2
    </div>
    <div onclick="dianji('div3')">
        div3
    </div>
    <div style="overflow: hidden; width: 300px; height: 300px; position: relative">
        <div id="div1" style="z-index: 1; position: absolute; float: left; background-color: Maroon;
            width: 300px; height: 300px">
            div1
        </div>
        <div id="div2" style="z-index: 1; position: absolute; float: left; background-color: Yellow;
            width: 300px; height: 300px">
            div2
        </div>
        <div id="div3" style="z-index: 1; position: absolute; float: left; background-color: Fuchsia;
            width: 300px; height: 300px">
            div3
        </div>
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title>无标题页</title>  <script src="jquery-1.4.1-vsdoc.js" type="text/javascript"></script>  <script type="text/javascript">
      var divindex=1;
       
      function dianji(id){
    document.getElementById(id).style.right="300px";
    document.getElementById(id).style.zIndex=divindex+1;
    divindex=divindex+1;
       
    var d=0;
       
    bw1= self.setInterval("fangfa('"+id+"',"+d+")",1);
       
      }
      function fangfa(id,d){
       
    var a=document.getElementById(id).style.left;
    a=a.substr(0,a.length-2);
       
    var b = (a*1)+1;
     
    document.getElementById(id).style.left=b+"px";
       
    if(d>300){
       
    self.clearInterval(bw1); 
    }
    d++;
    //alert(d);
      }
      </script></head>
    <body>
      <form id="form1" runat="server">
      <div onclick="dianji('div1')">
      div1
      </div>
      <div onclick="dianji('div2')">
      div2
      </div>
      <div onclick="dianji('div3')">
      div3
      </div>
      <div style="overflow: hidden; width: 300px; height: 300px; position: relative">
      <div id="div1" style="z-index: 1; position: absolute; float: left; background-color: Maroon;
      width: 300px; height: 300px">
      div1
      </div>
      <div id="div2" style="z-index: 1; position: absolute; float: left; background-color: Yellow;
      width: 300px; height: 300px">
      div2
      </div>
      <div id="div3" style="z-index: 1; position: absolute; float: left; background-color: Fuchsia;
      width: 300px; height: 300px">
      div3
      </div>
      </div>
      </form>
    </body>
    </html>
    楼主,帮你搞定
      

  2.   

    楼主把这句改一下,setInterval,里面的函数不能带参数的,改成下面的
    bw1 = self.setInterval(function () { fangfa(id, d) }, 1);