var delta=0.8;
var collection;
var closeB=false;
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()',1);
  }
}
function play()
{
if(screen.width<=1024 || closeB)
{
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?0:-0)*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?0:-0)*Math.ceil(Math.abs(dy));
followObj.style.top=followObj.offsetTop+dy;
}
followObj.style.display = '';
}
}
function closeBanner()
{
closeB=true;
return;
} var theFloaters = new floaters();
//
theFloaters.addItem('followDiv1','document.body.clientWidth-118',50,'<img src=images/close1.gif onClick="closeBanner();"><iframe src="/ads/right.html" width="120" marginwidth="0" height="600" marginheight="0" align="top" scrolling="no" frameborder="0" allowtransparency=true></iframe><img src=images/close1.gif onClick="closeBanner();">');
theFloaters.addItem('followDiv2',1,50,'<img src=images/close1.gif onClick="closeBanner();"><iframe src="/ads/left.html" width="120" marginwidth="0" height="600" marginheight="0" align="top" scrolling="no" frameborder="0" allowtransparency=true></iframe><img src=images/close1.gif onClick="closeBanner();">');
theFloaters.play();这个段广告在不加
<!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">
这个带的时候是正常的,因为网站是div+css所以必须加,加入以后代码就在网站最底部,把网站拉长了,不能正常运行。
希望高手改下。

解决方案 »

  1.   

    document.body 都改成 document.documentElement
      

  2.   

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>标准对联广告Js代码</title>
    <style type="text/css">
    <!--
    #lovexin12,#lovexin14{
    width:90px;
    height:230px;
    background-color:#ededed;
    border:1px solid #ddd;
    }
    html,body{
    height:1203px;
    }
    #mm{
    height:1000px;
    }
    -->
    </style><script language="JavaScript" type="text/javascript">
    lastScrollY=0;
    function heartBeat(){ 
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
    diffY = document.documentElement.scrollTop;
    else if (document.body)
    diffY = document.body.scrollTop
    else
    {/*Netscape stuff*/}
    percent=.1*(diffY-lastScrollY); 
    if(percent>0)percent=Math.ceil(percent); 
    else percent=Math.floor(percent); 
    document.getElementById("lovexin12").style.top=parseInt(document.getElementById
    ("lovexin12").style.top)+percent+"px";
    document.getElementById("lovexin14").style.top=parseInt(document.getElementById
    ("lovexin12").style.top)+percent+"px";
    lastScrollY=lastScrollY+percent; 
    }
    suspendcode12="<DIV id=\"lovexin12\" style='left:2px;POSITION:absolute;TOP:120px;'>ad1</div>"
    suspendcode14="<DIV id=\"lovexin14\" style='right:2px;POSITION:absolute;TOP:120px;'>ad2</div>"
    document.write(suspendcode12); 
    document.write(suspendcode14); 
    window.setInterval("heartBeat()",1);
    </script>
    </head>
    <body>
    <div id="mm"></div>
    </body>
    </html>
      

  3.   

    我要调用:/ads/right.html和/ads/left.html
    是google adsense广告,4楼的可以做到吗?
    具体怎么改?
      

  4.   

    我要的是可以调静态页的对联就是对联调的<iframe src="/ads/left.html" width="120" marginwidth="0" height="600" marginheight="0" align="top" scrolling="no" frameborder="0" allowtransparency=true></iframe>这个样子的。