求首页对联广告代码

来源:百度知道 编辑:UC知道 时间:2024/08/24 06:06:08
想在首页加个对联广告,分开的那种,左边是左边的,右边是右边的,然后是插入JS文件,方便以后更改,请问改如何添加代码?

复制下面代码放到js文件里就行了 导入用<script language="javascript" src="你的js文件名.js"></script>放到你的首页就可以了 你应该满意这段代码的效果吧 兼容firefoxf/ie/chrome

以下是js文件代码直接复制即可:
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*/}
//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("LeftAd").style.top=parseInt(document.getElementById("LeftAd").style.top)+percent+"px";
document.getElementById("RightAd").style.top=parseInt(document.getElementById("LeftAd").style.top)+percent+"px";
lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
suspendco