二个js实现的网页对联广告代码

发布时间:2019-11-14编辑:脚本学堂
二例网页对联广告js代码,在网页中显示对联广告,是点击量相对多的一块广告,js对联广告如何实现呢,可以参考下本文的二个例子,第二款js对联广告本站测试完全可用。

例1,js对联广告代码。
 

复制代码 代码示例:
<script>
var closebuttonhtml = '<div align="right" style="position: absolute;top:0px;right:0px;margin:2px;padding:2px;z-index:2000;"><a href="网页特效:;" onclick="hidead()" style="color:red;text-decoration:none;font-size:12px;">关闭</a></div>';
lastscrolly=0;
function heartbeat(){ var diffy;if (document.documentelement && document.documentelement.scrolltop)diffy = document.documentelement.scrolltop;else if (document.body)diffy = document.body.scrolltopelse{/*netscape stuff*/}percent=.1*(diffy-lastscrolly); if(percent>0)percent=math.ceil(percent); else percent=math.floor(percent); document.getelementbyid("lovexin12").style.top=parseint(document.getelementbyid("lovexin12").style.top)+percent+"px";document.getelementbyid("lovexin14").style.top=parseint(document.getelementbyid("lovexin12").style.top)+percent+"px";lastscrolly=lastscrolly+percent; }suspendcode12="<div id="lovexin12" style='left:2px;position:absolute;top:120px;width:90px;height:230px;background-color:#ededed;border:1px solid #ddd;'>"+closebuttonhtml+"<img src="/images/bq100.gif"/></div>"suspendcode14="<div id="lovexin14" style='right:2px;position:absolute;top:120px;width:90px;height:230px;background-color:#ededed;border:1px solid #ddd;'>"+closebuttonhtml+"<img src="/images/bq100.gif"/></div>"document.write(suspendcode12); document.write(suspendcode14); window.setinterval("heartbeat()",1);function hidead(){ document.getelementbyid("lovexin12").style.display="none"; document.getelementbyid("lovexin14").style.display="none";}
</script>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3c.org/tr/1999/rec-html401-19991224/loose.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=gb2312" /><title>标准对联广告js代码</title><style type="text/css教程"><!--html,body{height:1203px;}#mm{height:1000px;}--></style>
<script language="javascript" type="text/javascript" src="scroolad.js"></script></head><body><div id="mm"></div></body></html>

例2,js对联广告代码。
 

复制代码 代码示例:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>js对联广告代码</title>
<script language="javascript" type="text/javascript">
<!--对联代码开始-->
//<![cdata[
var adleftsrc = ""//图片地址
var adleftflash = "flash"
var adlefthref = ""
var adleftwidth = 85
var adleftheight = 255
var adrightsrc = ""//图片地址
var adrightflash = ""
var adrighthref = ""
var adrightwidth = 85
var adrightheight = 255
var margintop = 200 //在这里更改距离浏览器底端的高度
var marginleft = 15//在这里更改距离浏览器右端的高度
var navuseragent = navigator.useragent
function load(){
 judge();
 move();
}
function move() {
 judge();
 settimeout("move();",80)
}
function judge(){
 if (navuseragent.indexof("firefox") >= 0 || navuseragent.indexof("opera") >= 0) {
  if (adleftsrc != "") {document.getelementbyid("adleftfloat").style.top = (document.body.scrolltop?document.body.scrolltop:document.documentelement.scrolltop) + ((document.body.clientheight > document.documentelement.clientheight)?document.documentelement.clientheight:document.body.clientheight) - adleftheight - margintop + 'px';}
  if (adrightsrc != "") {
document.getelementbyid("adrightfloat").style.top = (document.body.scrolltop?document.body.scrolltop:document.documentelement.scrolltop) + ((document.body.clientheight > document.documentelement.clientheight)?document.documentelement.clientheight:document.body.clientheight) - adrightheight - margintop + 'px';
document.getelementbyid("adrightfloat").style.left = ((document.body.clientwidth > document.documentelement.clientwidth)?document.body.clientwidth:document.documentelement.clientwidth) - adrightwidth - marginleft + 'px';
  }
 }
 else{
  if (adleftsrc != "") {document.getelementbyid("adleftfloat").style.top = (document.body.scrolltop?document.body.scrolltop:document.documentelement.scrolltop) + ((document.documentelement.clientheight == 0)?document.body.clientheight:document.documentelement.clientheight) - adleftheight - margintop + 'px';}
  if (adrightsrc != "") {
document.getelementbyid("adrightfloat").style.top = (document.body.scrolltop?document.body.scrolltop:document.documentelement.scrolltop) + ((document.documentelement.clientheight == 0)?document.body.clientheight:document.documentelement.clientheight) - adrightheight - margintop + 'px';
document.getelementbyid("adrightfloat").style.left = ((document.documentelement.clientwidth == 0)?document.body.clientwidth:document.documentelement.clientwidth) - adrightwidth - marginleft + 'px';
  }
 }
 if (adleftsrc != "") {document.getelementbyid("adleftfloat").style.left = marginleft + 'px';}
}
if (adleftsrc != "") {
 if (adleftflash == "flash") {
 document.write("<div id="adleftfloat" style="position: absolute;width:" + adleftwidth + ";height:100px; font-size:12px;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_left();void(0);";>");
 
  document.write("<div id="float" style="width:" + adleftwidth + ";"><embed src="" + adleftsrc + "" quality="high" width="" + adleftwidth + "" height="" + adleftheight + "" type="application/x-shockwave-flash"></embed></div>");
  document.write("</div>");
 }
 else{
 document.write("<div id="adleftfloat" style="position: absolute;width:" + adleftwidth + ";height:100px; font-size:12px;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_left();void(0);";>");
 
  document.write("<div id="float" style="width:" + adleftwidth + ";"><a href="" + adlefthref +"" target=_blank><img src="" + adleftsrc + "" width="" + adleftwidth + "" height="" + adleftheight + "" border="0" ></a></div>");
  document.write("</div>");
 }
}

if (adrightsrc != "") {
 if (adrightflash == "flash") {
 document.write("<div id="adrightfloat" style="position: absolute;width:" + adrightwidth + ";height:100px; font-size:12px;text-align:right;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_right();void(0);";>");
 
  document.write("<div id="float" style="width:" + adrightwidth + ";"><embed src="" + adrightsrc + "" quality="high" width="" + adleftwidth + "" height="" + adrightheight + "" type="application/x-shockwave-flash"></embed></div>");
  document.write("</div>");
 }
 else{
 document.write("<div id="adrightfloat" style="position: absolute;width:" + adrightwidth + ";height:100px; font-size:12px;text-align:right;"><img src="images/close.gif" width="12" border="0" height="12" onmousedown="javascript:close_float_right();void(0);";>");
 
  document.write("<div id="float" style="width:" + adrightwidth + ";"><a href="" + adrighthref +"" target=_blank><img src="" + adrightsrc + ""width="" + adleftwidth + "" height="" + adrightheight + "" border="0" ></a></div>");
  document.write("</div>");
 }
}
load();
function close_float_right(){
document.getelementbyid("adrightfloat").style.display="block";}
function close_float_left(){
document.getelementbyid("adleftfloat").style.display="block";} //]]>
<!--对联代码结束-->
</script>
</head>
<body>
</body>
</html>