首页 > 代码库 > 两侧浮动广告代码

两侧浮动广告代码


两侧浮动广告代码


SCRIPT language=JavaScript src=http://www.mamicode.com/menus.js
Script
DIV id=floater1 style=Z-INDEX 100; LEFT 10px; VISIBILITY visible; WIDTH 100px; POSITION absolute; TOP 160px; height 100px; 
左边的东西,可以是图片,表格,可以设置其宽,高
DIV 
DIV id=floater style=Z-INDEX 100; RIGHT 10px; VISIBILITY visible; WIDTH 100px; POSITION absolute; TOP 160px; left 890px; 
右边的东西,可以是图片,表格,可以设置其宽高
DIV 
menus.js
self.onError = null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers)  1  0;
IE = (document.all)  1 0;
function heartBeat(objectid) {
if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY) {
percent = .1  (diffY - lastScrollY);
if(percent  0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) {
objectid = objectid.split(;);
for (i = 0; i  objectid.length; i++) eval(document.all.+objectid).style.pixelTop += percent;
}
if(NS) {
objectid = objectid.split(;);
for (i = 0; i  objectid.length; i++) eval(document.+objectid).top += percent;
}
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .1  (diffX - lastScrollX);
if(percent  0) percent = Math.ceil(percent);JS代码
else percent = Math.floor(percent);
if(IE) {
objectid = objectid.split(;);
for (i = 0; i  objectid.length; i++) eval(document.all.+objectid).style.pixelLeft += percent;
}
if(NS) {
objectid = objectid.split(;);
for (i = 0; i  objectid.length; i++) eval(document.+objectid).left += percent;   
}
lastScrollX = lastScrollX + percent;

}
if(NS  IE) action = window.setInterval(heartBeat(‘floater;floater1‘), 2);


下载地址:http://www.huiyi8.com/guanggaodaima/fudong/(转载请注明此处)

两侧浮动广告代码