对联广告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');
}
function MoveLeftLayer(layerName) {
var x = 5;
var y = 100;// 左侧距离页首高度
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 closediv(obj)
{
document.getElementById(obj).style.display = "none";
}
function MoveRightLayer(layerName) {
var x = 5;
var y = 100;// 右侧距离页首高度
var diff = (document.body.scrollTop + y - document.all.AdLayer2.style.posTop)*.40;
var y = document.body.scrollTop + y - diff;
eval("document.all." + layerName + ".style.posTop = y");
eval("document.all." + layerName + ".style.posRight = x");
setTimeout("MoveRightLayer('AdLayer2');", 20);
}
document.write("<div id=AdLayer1 style='position: absolute;visibility:hidden;z-index:1'><img src=Image/left.gif border='0'><div style='width:90px;text-align:center'><a href='#' onclick=closediv('AdLayer1')>关闭</a></div></div>"
+"<div id=AdLayer2 style='position: absolute;visibility:hidden;z-index:1'><img src=Image/right.gif border='0'><div style='width:90px;text-align:center'><a href='#' onclick=closediv('AdLayer2')>关闭</a></div></div>");
initEcAd()