网站建设——广告对联代码

<script language="JavaScript" type="text/javascript">
lastScrollY=0;
function heartBeat(){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
    diffY = document.documentElement.scrollTop;
else if (document.body)
    diffY = document.body.scrollTop
else
    {/*Netscape stuff*/}
//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("left").style.top=parseInt(document.getElementById
("left").style.top)+percent+"px";
document.getElementById("right").style.top=parseInt(document.getElementById
("left").style.top)+percent+"px";
lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
ad1="<DIV id=/"left/" style='left:5px;POSITION:absolute;TOP:120px;'><img border=0 src=左图路径><div align=left><a href=# onclick=/"left.style.visibility='hidden'/"><font style='color:#003366;font-size:9pt;font-family:Wingdings;text-decoration:none;'>x</font></a></div></div>"
ad2="<DIV id=/"right/" style='right:5px;POSITION:absolute;TOP:120px;'><img border=0 src=右图路径><div align=right><a href=# onclick=/"right.style.visibility='hidden'/"><font style='color:#003366;font-size:9pt;font-family:Wingdings;text-decoration:none;'>x</font></a></div></div>"
document.write(ad1);
document.write(ad2);
window.setInterval("heartBeat()",1);
</script>
直接放在静态页中的对联广告代码(有关闭按钮,两个同时关闭):
-----------------------------------------------------------------------------------------------------------------
<SCRIPT LANGUAGE="JavaScript">
<!-- // 对联广告代码开始
var showad = true;
var Toppx = 30; //上端位置
var AdDivW = 110; //宽度
var AdDivH = 6; //高度
var PageWidth = 800; //页面多少宽度象素下正好不出现左右滚动条
var MinScreenW = 1024; //显示广告的最小屏幕宽度象素
var ClosebuttonHtml = '<div align="right" style="position: absolute;top:0px;right:0px;margin:0px;padding:0px;z-index:2000;"><a href="javascript:;" onclick="hidead()" style="color:white;text-decoration:none;font-size:12px;">关闭</a></div>'
var AdContentHtml1 = '<img border="0" src="所调用文件的路径">'; //指定左侧的广告图片位置
var AdContentHtml2 = '<img border="0" src="所调用文件的路径">'; //指定右侧的广告图片位置
document.write ('<div id="Javascript.LeftDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+'<div>'+AdContentHtml1+'</div></div>');
document.write ('<div id="Javascript.RightDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ClosebuttonHtml+'<div>'+AdContentHtml2+'</div></div>');
function scall(){
if(!showad){return;}
if (window.screen.width<MinScreenW){
alert("临时提示:/n/n显示器分辨率宽度小于"+MinScreenW+",不显示广告");
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
return;
}
var Borderpx = ((window.screen.width-PageWidth)/2-AdDivW)/2;
document.getElementById("Javascript.LeftDiv").style.display="";
document.getElementById("Javascript.LeftDiv").style.top=document.body.scrollTop+Toppx;
document.getElementById("Javascript.LeftDiv").style.left=document.body.scrollLeft+Borderpx;
document.getElementById("Javascript.RightDiv").style.display="";
document.getElementById("Javascript.RightDiv").style.top=document.body.scrollTop+Toppx;
document.getElementById("Javascript.RightDiv").style.left=document.body.scrollLeft+document.body.clientWidth-document.getElementById("Javascript.RightDiv").offsetWidth-Borderpx;
}
function hidead()
{
showad = false;
document.getElementById("Javascript.LeftDiv").style.display="none";
document.getElementById("Javascript.RightDiv").style.display="none";
}
window.onscroll=scall;
window.onresize=scall;
window.onload=scall;
//--> //对联广告代码结束
</SCRIPT>
JS调用 对联广告代码:
-------------------------------------------------------------------
这是网页内放的代码:
<!--对联广告条-->
<SCRIPT FOR='EccoolAd' EVENT='fscommand()' LANGUAGE='JavaScript'>
AdLayer1.style.visibility='hidden';
AdLayer2.style.visibility='hidden';
</script>
<script src=EccoolAd.js></script>
flash中关闭按扭为close_btn
flash文件EccoolAdb.swf可以把下面JS中代码改为你的FLASH名
flash中关闭代码:
close_btn.onRelease = function() {
fscommand("quit");//作为HTML中EccoolAD对象的响应事件
}
这是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 = 340;
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 = 340;
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'><EMBED src='EccoolAda.swf' quality=high WIDTH=100 HEIGHT=100 TYPE='application/x-shockwave-flash' id=EccoolAd></EMBED></div>"
+"<div id=AdLayer2 style='position: absolute;visibility:hidden;z-index:1'><EMBED src='EccoolAdb.swf' quality=high WIDTH=100 HEIGHT=100 TYPE='application/x-shockwave-flash' id=EccoolAd></EMBED></div>");
initEcAd()

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭