// JavaScript Document
//<script language=javascript>
var specialcode="<DIV id=searchspe style='Z-INDEX: 100; POSITION: absolute; TOP: 65px; border:1px solid #999999;'><TABLE width='130' cellSpacing=4 bgcolor='#F4EDA9' cellPadding=0 style='font-size:12px;color:#666666'><TR><TD height=20> <img src='images/2010/dh5.jpg' alt='在线咨询' width='84' height='24' /></TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=35>关闭</TD></TR></TABLE><table border='0' cellpadding='0' cellspacing='0' id='table1'><tr><td><iframe height='185' width='130' src='ad.htm' frameborder=0 allowTransparency='true'></iframe></td></tr></table></DIV>";
var xxx=window.screen.width-155;
document.write(specialcode);
lastScrollY=-100;
function heartBeat0()
{
diffY=document.documentElement.scrollTop;
percent=.1*(diffY-lastScrollY);  
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.all.searchspe.style.pixelTop+=percent;
document.all.searchspe.style.posLeft=xxx;
lastScrollY=lastScrollY+percent;
}
window.setInterval("heartBeat0()",1);
  ///<script>

解决方案 »

  1.   

    正确的写法
    <script>
    var lastScrollY=0;
    var specialcode="<DIV id=searchspe style='Z-INDEX: 100; POSITION: absolute; TOP: 65px; border:1px solid #999999;'><TABLE width='130' cellSpacing=4 bgcolor='#F4EDA9' cellPadding=0 style='font-size:12px;color:#666666'><TR><TD height=20> <img src='images/2010/dh5.jpg' alt='在线咨询' width='84' height='24' /></TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=35>关闭</TD></TR></TABLE><table border='0' cellpadding='0' cellspacing='0' id='table1'><tr><td><iframe height='185' width='130' src='ad.htm' frameborder=0 allowTransparency='true'></iframe></td></tr></table></DIV>";
    var xxx=window.screen.width-155;
    document.write(specialcode);
    lastScrollY=-100;
    function heartBeat0()
    {
    diffY=document.documentElement.scrollTop==0?document.body.scrollTop:document.documentElement.scrollTop;
    percent=.1*(diffY-lastScrollY);  
    if(percent>0)percent=Math.ceil(percent);
    else percent=Math.floor(percent);
    document.getElementById("searchspe").style.top=percent+parseInt(document.getElementById("searchspe").style.top)+"px";
    document.getElementById("searchspe").style.left=xxx+"px";
    lastScrollY=lastScrollY+percent;
    }
    window.setInterval("heartBeat0()",1);
    </script>
      

  2.   

    <script language="javascript">
    var specialcode="<DIV id=searchspe style='Z-INDEX: 100; POSITION: absolute; TOP: 65px;right:0px; border:1px solid #999999;'><TABLE width='130' cellSpacing=4 bgcolor='#F4EDA9' cellPadding=0 style='font-size:12px;color:#666666'><TR><TD height=20> <img src='images/2010/dh5.jpg' alt='在线咨询' width='84' height='24' /></TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=35>关闭</TD></TR></TABLE><table border='0' cellpadding='0' cellspacing='0' id='table1'><tr><td><iframe height='185' width='130' src='ad.htm' frameborder=0 allowTransparency='true'></iframe></td></tr></table></DIV>";
    document.write(specialcode);
    lastScrollY=-100;
    function heartBeat0()
    {
    diffY=document.documentElement.scrollTop;
    percent=.1*(diffY-lastScrollY);  
    if(percent>0)percent=Math.ceil(percent);
    else percent=Math.floor(percent);
    document.getElementById("searchspe").style.top=(parseInt(document.getElementById("searchspe").style.top)+percent)+"px";
    lastScrollY=lastScrollY+percent;
    }
    window.setInterval("heartBeat0()",10);
    </script>