Blog

作对联浮动广告代码

点击查看原图

很多网站都在首页上打出了对联广告。您想制作对联浮动广告吗?现在我就来介绍一下常见的对联浮动广告效果的代码。

如下所示: 

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 = 165 ;

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 = y”);

eval(“document.all.” + layerName + “.style.posLeft = x”);

setTimeout(“MoveLeftLayer(’AdLayer1’);”, 20);

}

function MoveRightLayer(layerName) {

var x = 5;

var y = 165;

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’><a href=连接地址 target=_blank ><img src=图片地址 border=0></a></div>”

+”<div id=AdLayer2 style=’position: absolute;visibility:hidden;z-index:1’><a href=连接地址 target=_blank ><img src=图片地址 border=0></a></div>”);

initEcAd()

  把上面的代码另存为一个*.JS文件,然后在想实现此效果的页面<head></head>之间加上一列代码:

<SCRIPT FOR=’EccoolAd’ EVENT=’fscommand()’ LANGUAGE=’javascript’>

AdLayer1.style.visibility=’hidden’;

AdLayer2.style.visibility=’hidden’;

</script>

<script src=*.js></script>

  调用即可,*代表你另存的文件名!注意修改广告图片地址和连接地址!相应的参数可以自行调整!

注:如果想用flash图片,将<a href=连接地址 target=_blank ><img src=图片地址 border=0></a>改为<EMBED src=*.swf></EMBED>即可。图片链接最好用绝对地址,相对地址有时可能会无法显示。

没有评论

Leave a Reply