<body style="margin:0px; padding:0px;">
<div id='ss' style="height:300px; width:400px; border:10px solid #999999; position:absolute; left:50px; top:50px; overflow:hidden">
<img src='http://hiphotos.baidu.com/qwjmys/mpic/item/691db5065867c6ef7b894793.jpg' height="300" width="400px;">
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<div id='sss'></div>
<div id='ssss'></div>
<script>
function $(Id){return document.getElementById(Id)};
var CurrentStyle = function(element){return element.currentStyle || document.defaultView.getComputedStyle(element, null);};
var time = null;
var step =50;
var i =j=0;
var ischange =false;
var tatol=[parseInt(CurrentStyle($('ss')).left),parseInt(CurrentStyle($('ss')).top),parseInt(CurrentStyle($('ss')).width),parseInt(CurrentStyle($('ss')).height)];
var Tween = {
    Quintic:{
easeOut: function(t,b,c,d){
return c*((t=t/d-1)*t*t*t*t + 1) + b;
}
            }
}
document.onclick =function(event){
     i = 0;
 clearTimeout(time)
     var e = event||window.event;
 var current = [parseInt(CurrentStyle($('ss')).left),parseInt(CurrentStyle($('ss')).top),parseInt(CurrentStyle($('ss')).width),parseInt(CurrentStyle($('ss')).height)] 
     if(document.all){current[2]=current[2]+2*parseInt($('ss').style.borderLeftWidth);current[3]=current[3]+2*parseInt($('ss').style.borderLeftWidth);}
     //就在这个地方 我加上了边框的高度了 但是在ff下还是边框还是在呀
     if(!ischange)
 {  ischange =true;
 var _x = e.clientX-parseInt(current[0]);
     var _y = e.clientY-parseInt(current[1]);
 time =setInterval(function(){
  i++;
  if(i>step){clearTimeout(time);return}
  $('ss').style.width  = current[2]-MoveTo(i,0,current[2],step)+'px'; 
  $('ss').style.height = current[3]-MoveTo(i,0,current[3],step)+'px'; 
  $('ss').style.left   = parseInt(current[0])+MoveTo(i,0,_x,step)+'px';
  $('ss').style.top    = parseInt(current[1])+MoveTo(i,0,_y,step)+'px'; 
 },2)
 }
 else
 {
ischange =false;
time = setInterval(function(){
    i++
if(i>step){clearTimeout(time);return}
$('ss').style.width  = current[2]+MoveTo(i,0,tatol[2]-current[2],step)+'px'; 
$('ss').style.height = current[3]+MoveTo(i,0,tatol[3]-current[3],step)+'px'; 
$('ss').style.left   = current[0]-MoveTo(i,0,current[0]-tatol[0],step)+'px';
$('ss').style.top    = current[1]-MoveTo(i,0,current[1]-tatol[1],step)+'px';
},2)
 }
}function MoveTo(t,b,c,d){
 return Math.round(Tween.Quintic.easeOut(t,b,c,d));
}
</script>
</body>

解决方案 »

  1.   

    border也相应变化
    <body style="margin:0px; padding:0px;">
    <div id='ss' style="height:300px; width:400px; border:10px solid #999999; position:absolute; left:50px; top:50px; overflow:hidden">
    <img src='http://hiphotos.baidu.com/qwjmys/mpic/item/691db5065867c6ef7b894793.jpg' height="300" width="400px;">
    </div>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <div id='sss'></div>
    <div id='ssss'></div>
    <script>
    function $(Id){return document.getElementById(Id)};
    var CurrentStyle = function(element){return element.currentStyle || document.defaultView.getComputedStyle(element, null);};
    var time = null;
    var step =50;
    var i =j=0;
    var ischange =false;
    var tatol=[parseInt(CurrentStyle($('ss')).left),parseInt(CurrentStyle($('ss')).top),parseInt(CurrentStyle($('ss')).width),parseInt(CurrentStyle($('ss')).height)];
    var Tween = {
        Quintic:{
                    easeOut: function(t,b,c,d){
                        return c*((t=t/d-1)*t*t*t*t + 1) + b;
                    }
                }
    }
    document.onclick =function(event){
         i = 0;
         clearTimeout(time)
         var e = event||window.event;
         var current = [parseInt(CurrentStyle($('ss')).left),parseInt(CurrentStyle($('ss')).top),parseInt(CurrentStyle($('ss')).width),parseInt(CurrentStyle($('ss')).height)] 
         if(!ischange)
         {
             ischange =true;
             var _x = e.clientX-parseInt(current[0]);
             var _y = e.clientY-parseInt(current[1]);
             time =setInterval(function(){
                  i++;
                  if(i>step){clearTimeout(time);return}
          $('ss').style.borderWidth= parseInt(10*(1-i/step)) + 'px';
                  $('ss').style.width  = current[2]-MoveTo(i,0,current[2],step)+'px'; 
                  $('ss').style.height = current[3]-MoveTo(i,0,current[3],step)+'px'; 
                  $('ss').style.left   = parseInt(current[0])+MoveTo(i,0,_x,step)+'px';
                  $('ss').style.top    = parseInt(current[1])+MoveTo(i,0,_y,step)+'px'; 
             },2)
         }
         else
         {  $('ss').style.borderWidth='10px';
            ischange =false;
            time = setInterval(function(){
                i++
                if(i>step){clearTimeout(time);return}
                $('ss').style.width  = current[2]+MoveTo(i,0,tatol[2]-current[2],step)+'px'; 
                $('ss').style.height = current[3]+MoveTo(i,0,tatol[3]-current[3],step)+'px'; 
                $('ss').style.left   = current[0]-MoveTo(i,0,current[0]-tatol[0],step)+'px';
                $('ss').style.top    = current[1]-MoveTo(i,0,current[1]-tatol[1],step)+'px';
            },2)
         }
    }function MoveTo(t,b,c,d){
         return Math.round(Tween.Quintic.easeOut(t,b,c,d));
    }
    </script>
    </body>
      

  2.   

    应该用borderWidth不是borderLeftWidth
      

  3.   

    to 2楼  本来就晚半个小时下班  在整理下发帖,额 额 回家要跪CPU的!~