首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

劳驾高手看一下,这段对联的JS,为什么放入页面后不能随滚动条上下移动

2011-12-17 
麻烦高手看一下,这段对联的JS,为什么放入页面后不能随滚动条上下移动vardelta0.8varcollectionfunction

麻烦高手看一下,这段对联的JS,为什么放入页面后不能随滚动条上下移动
var   delta=0.8;
var   collection;
function   floaters()   {
this.items=   [];
this.addItem=   function(id,x,y,content)
    {
document.write( ' <DIV   id= '+id+ '   style= "Z-INDEX:   10;   POSITION:   absolute;     width:80px;   height:60px;left: '+(typeof(x)== 'string '?eval(x):x)+ ';top: '+(typeof(y)== 'string '?eval(y):y)+ ' "> '+content+ ' </DIV> ');

var   newItem=   {};
newItem.object=   document.getElementById(id);
newItem.x=   x;
newItem.y=   y;

this.items[this.items.length]=   newItem;
    }
this.play=   function()
    {
collection=   this.items
setInterval( 'play() ',30);
    }
}
function   play()
{
if(screen.width <=800)
{
for(var   i=0;i <collection.length;i++)
{
collection[i].object.style.display=   'none ';
}
return;
}
for(var   i=0;i <collection.length;i++)
{
var   followObj=   collection[i].object;
var   followObj_x=   (typeof(collection[i].x)== 'string '?eval(collection[i].x):collection[i].x);
var   followObj_y=   (typeof(collection[i].y)== 'string '?eval(collection[i].y):collection[i].y);

if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x))   {
var   dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
dx=(dx> 0?1:-1)*Math.ceil(Math.abs(dx));
followObj.style.left=followObj.offsetLeft+dx;
}

if(followObj.offsetTop!=(document.body.scrollTop+followObj_y))   {
var   dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
dy=(dy> 0?1:-1)*Math.ceil(Math.abs(dy));
followObj.style.top=followObj.offsetTop+dy;
}
followObj.style.display=   ' ';
}
}
var   theFloaters=   new   floaters();
//
theFloaters.addItem( 'followDiv1 ', 'document.body.clientWidth-106 ',80, ' <a   href=http://www.red.net.cn/style/info/hosting.asp   target=_blank> <img   src=http://www.knowsky.com/ad/100300.gif   width=100   height=300   border=0> </a>   ');
theFloaters.addItem( 'followDiv2 ',6,80, ' ');
theFloaters.play();

我的网页中很简单。
<%@LANGUAGE= "VBSCRIPT "   CODEPAGE= "936 "%>
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN "   "http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 无标题文档 </title>
</head>

<body>
<script   src= "/Index/JS/flag.js "> </script>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>


<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<table   width= "800 "   border= "1 ">
    <tr>
        <td> &nbsp; </td>
        <td> &nbsp; </td>
        <td> &nbsp; </td>
    </tr>
    <tr>
        <td> &nbsp; </td>
        <td> &nbsp; </td>
        <td> &nbsp; </td>
    </tr>
    <tr>
        <td> &nbsp; </td>
        <td> &nbsp; </td>
        <td> &nbsp; </td>
    </tr>
</table>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> &nbsp; </p>
<p> </p>
</body>
</html>
就这样都不能动,然而我看到这段代码在别的网页上是可以动的。不知为什么。

[解决办法]
沙发(。。)

热点排行