JS 浮动广告图片
代码:
function initEcAd() {
document.all.AdLayer1.style.posTop = -200;
document.all.AdLayer1.style.visibility = 'visible'
document.all.AdLayer2.style.posTop = -200;
document.all.AdLayer2.style.visibility = 'visible'
MoveLeftLayer('AdLayer1');
// MoveRightLayer('AdLayer2')
MoveLeftLayer1("AdLayer2");
}
function MoveLeftLayer(layerName) {
var x = 0;
var y = 500; // 左侧广告距离页首高度
var diff = (document.body.scrollTop + y - document.all.AdLayer1.style.posTop) * .40;
var y = document.body.scrollTop + y - diff;
eval("document.all." + layerName + ".style.posTop = parseInt(y)");
eval("document.all." + layerName + ".style.posLeft = x");
setTimeout("MoveLeftLayer('AdLayer1');", 20);
}
//左侧第二张图片
function MoveLeftLayer1(layerName) {
var x = 0;
var y = 625;
var diff = (document.body.scrollTop + y - document.all.AdLayer2.style.posTop) * .40;5
var y = document.body.scrollTop + y - diff;
eval("document.all." + layerName + ".style.posTop = parseInt(y)");
eval("document.all." + layerName + ".style.posLeft = x");
setTimeout("MoveLeftLayer('AdLayer2');", 20);
}
document.write("<div id=AdLayer1 style='position: absolute;visibility:hidden;z-index:1'><a href='' target='_blank'><img src=../images/guanggao.jpg border='0'></a></div>"
+ "<div id=AdLayer2 style='position: absolute;visibility:hidden;z-index:1'><a href='' target='_blank'><img src=../images/guanggao.jpg border='0'></a></div>");
initEcAd();
问题:图片的高度是115px,而我给出了125px的空间,却重叠了.请问哪里错了.
------解决方案--------------------直接position:fixed定位就好了,不需要js。。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"