是要这种效果吗?
<html>
<head>
<title> New Document </title>
</head>
<body bgcolor="#FFFFFF">
<div id="oTime" style="position:absolute;top:30;left:30;width:100;height:60;border:solid 1px blue" align="center"><img src="http://expert.csdn.net/images/csdn.gif"></div>
<br>
<br>
<br>
<br>
<br>
<br><br><br>
<br>
<br>
<br>
<br><br><br>
<br>
<br>
<br>
<br><br>
<br>
<br>
<br>
<br><br>
<br>
<br>
<br>
<br>
<br><br>
<br>
<br>
<br>
<br>
<br><br>
<br>
<br>
<br>
<br>
<br><br>
<br>
<br>
<br>
<br>
<br><br>
<script language="javascript">
<!--
var oTimeTop = oTime.style.pixelTop;
document.body.onscroll=function()
{
oTime.style.top = oTimeTop+ document.body.scrollTop;
}
//-->
</script>
</body>
</html>

解决方案 »

  1.   

    我想它缓缓的滑动到新位置。这是我已经写的代码。function keep(theName,theWantTop,theWantLeft)
    {
      theRealTop = parseInt(document.body.scrollTop);
      theTrueTop = theWantTop+theRealTop;
      document.all[theName].style.top = theTrueTop;
      theRealLeft = parseInt(document.body.scrollLeft);
      theTrueLeft = theWantLeft+theRealLeft;
      document.all[theName].style.left = theTrueLeft;
    }if (document.all.id1)
    {
      setInterval('keep("id1",0,0)',1000);
    }
      

  2.   

    楼主看看这段代码,可以上下缓缓的滑动了,左右你照着改吧,可能还有问题,你先看看
    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    </head>
    <body bgcolor="#FFFFFF">
    <div id="id1" style='position:absolute;'>
    <img id='imgtu' src='http://expert.csdn.net/images/csdn.gif'></div>
    </div>
    <p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>p<p>puuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
    <script language="JavaScript">
    <!--
    var i = 0;
    var top = 0;left=0;
    var a;
    function keep(theName,theWantTop,theWantLeft)
    {
      
      theRealTop = parseInt(document.body.scrollTop);
      theTrueTop = theWantTop+theRealTop;
      theRealLeft = parseInt(document.body.scrollLeft);
      theTrueLeft = theWantLeft+theRealLeft;
      
      if(theTrueTop >1)
      {
      if(i<theTrueTop || i==0)
      {
    document.all[theName].style.top = i;
    document.all[theName].style.left = theTrueLeft;
      }
      else
      {
    return;
    top = theTrueTop;
    left = theTrueLeft;
      }
         i+=1;
      }
    }
    function up(theName,theWantTop,theWantLeft)
    {
      theRealTop = parseInt(document.body.scrollTop);
      theTrueTop = theRealTop;
      theRealLeft = parseInt(document.body.scrollLeft);
      theTrueLeft = theRealLeft;
      
      if(theTrueTop >1)
      {
      if(i>theTrueTop)
      {
    document.all[theName].style.top = i;
    document.all[theName].style.left = theTrueLeft;
      }
      else
      {
    return;
      }
         i-=1;
      }
      
    }
    function cc()
    {
    top = document.body.scrollTop;
    if (i+1>top)
    {
      setInterval('keep("id1",0,0)',50);
    }
    if(i<top+1)
    {
    setInterval('up("id1",'+top+','+left+')',150);
    }
    }
    setInterval('cc()',1000);
    //-->
    </script>
    </body>
    </html>