浮动广告/对联广告问题 测试能动,放进页面不动
自己写的几句简单代码,新建一个HTML文件加进去能成功,能动,
<head>
<script language=javascript>
function Ad()
{
document.getElementById( "divLeft ").style.top=document.documentElement.scrollTop+100;
}
var begin= setInterval( "Ad() ",1000);
</script>
</head>
<body>
<table> (这个TABLE不用去管他,因为是新建的HTML,所以没内容,我把页面撑高一点 好拖动下拉时看浮动效果)
<tr>
<td height= "300 ">
1
</td>
</tr>
<tr>
<td height= "300 ">
2
</td>
</tr>
<tr>
<td height= "300 ">
2
</td>
</tr>
</table>
(下面这个就 浮动广告 用1234567代替内容)
<div id= "divLeft " style= "Z-INDEX: 100;POSITION: absolute; TOP: 51px;LEFT: 1px; ">
1234567
</div>
</body>
在新建的HTML里面正常。但是如果放到有大量内容的首页index.htm里面就不动了(准确的说是只动一下,打开页面的时候),但可以确定这个时候Ad()还是在不断执行的,在Ad()里加一个alert( "1 "),可以看到还是不停弹出窗口的,但div就是不动了,请问一下有遇到类似问题的朋友吗,还有怎么解决?谢谢
[解决办法]
[解决办法]
接分
[解决办法]
<div style= "OVERFLOW: hidden; HEIGHT: 120px "
加这个试试
[解决办法]
不是很清楚这个是为什么原因哈,会不会就是那个TABLE造成的呢?
[解决办法]
发个对联代码功楼主思考
---------------
<script src= "http://www.google-analytics.com/urchin.js " type= "text/javascript ">
</script>
<script type= "text/javascript ">
_uacct = "UA-1287176-1 ";
urchinTracker();
</script>
<script language= "javascript " type= "text/javascript ">
var delta=0.15
var collection;
function floaters() {
this.items = [];
this.addItem = function(id,x,y,content)
{
document.write( ' <DIV id= '+id+ ' style= "Z-INDEX: 0; 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() ',10);
}
}
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-105 ',200, ' <br> <a href= "../PageClour/PageColor.html " target=_blank> <img src= "../Image/Shop/PigRight.gif " width=100 height=300 border=0/> </a> ');
theFloaters.addItem( 'followDiv2 ',5,200, ' <br> <a href= "../PageClour/PageColor.html " target=_blank> <img src= "../Image/Shop/PigLeft.gif " width=100 height=300 border=0 /> </a> ');
theFloaters.play();
/*flash添加
var theFloaters = new floaters();
theFloaters.addItem( 'followDiv1 ', 'document.body.clientWidth-106 ',80, ' <br> <EMBED src= "*.swf " id= "veicon " quality=high PLUGINSPAGE= "http://www.macromedia.com/go/getflashplayer " TYPE= "application/x-shockwave-flash " WIDTH= "100 " HEIGHT= "300 "> </EMBED> ');
theFloaters.addItem( 'followDiv2 ',6,80, ' <br> <EMBED src= "*.swf " id= "veicon " quality=high PLUGINSPAGE= "http://www.macromedia.com/go/getflashplayer " TYPE= "application/x-shockwave-flash " WIDTH= "100 " HEIGHT= "300 "> </EMBED> ');
theFloaters.play(); */
</script>