在ecshop首页增加对联广告的方法
已经测试 兼容IE6,IE7,FIREFOX
1、首先将下面代码另存为 /js/scroll.js
suspendcode='<div id="AdLayer1" style="position: absolute;visibility:hidden;z-index:1000;"><a href="#" target="_blank"><img src="/images/ad_dl1.gif" width="100" height="300" border="0"></a><br><a href="javascript:hide()"><img src="/images/close_dl.gif" width="100" height="14" border="0" vspace="3" alt=""></a></div>';
document.write(suspendcode);
suspendcode='<div id="AdLayer2" style="position: absolute;visibility:hidden;z-index:1000;"><a href="#" target="_blank"><img src="/images/ad_dl1.gif" width="100" height="300" border="0"></a><br><a href="javascript:hide()"><img src="/images/close_dl.gif" width="100" height="14" border="0" vspace="3" alt=""></a></div>';
document.write(suspendcode);
var m_layer1,m_layer2;
function initMove() {
m_layer1=document.getElementById("AdLayer1");
m_layer2=document.getElementById("AdLayer2");
m_layer1.style.top = "-200px";
m_layer1.style.visibility = 'visible'
m_layer2.style.top = "-200px";
m_layer2.style.visibility = 'visible'
MoveLayers();
window.onscroll=MoveLayers;
}
function MoveLayers() {
var x = 5; // 左右边距
var y = 100; // 顶距
var st=document.documentElement.scrollTop;
var cw=document.documentElement.clientWidth;
var y = st + y;
m_layer1.style.top = y+"px";
m_layer1.style.left = x+"px";
m_layer2.style.top = y+"px";
m_layer2.style.left = cw-m_layer2.clientWidth-x+"px";
}
function hide()
{
document.getElementById("AdLayer1").style.visibility="hidden";
document.getElementById("AdLayer2").style.visibility="hidden";
}
window.setTimeout("initMove()",600);
2、然后修改 themes/模板文件夹/index.dwt
在</body>之前添加下面代码
<script language=JavaScript src="/js/scroll.js"></script>
3、下面是需要用到的广告图片和关闭按钮,下载并保存到 /images 下(注意是根目录下的 images 而不是模板目录下的那个 images)
实际应用中,把广告图片替换为你自己的就行了