JS实现广告顺序轮播和随机轮播四份代码
www.jz123.cn 2010-09-27 来源: 中国建站 责任编辑(袁袁) 我要投递新闻
广告代码1
<html> <head> <STYLE type=text/css>BODY {MARGIN-TOP: 0px; MARGIN-LEFT: 0px ;MARGIN-BOTTOM: 0px; MARGIN-RIGHT: 0px}</STYLE> </head> <body> <div id="marqueebox" style="margin-top:0px;width:369px;height:22px;float:left;line-height:22px;text-align:top;overflow:hidden "> <div> <a href="http://www.bankcha.com" target="_blank">第一个广告代码</a></div> <div> <a href="http://www.tianqila.com" target="_blank">第二个广告代码</a></div> <div> <a href="http://www.jz123.cn/" target="_blank">第三个广告代码</a></div> <div> <a href="http://www.huocheshike.cn" target="_blank">第四个广告代码</a></div> <div> <a href="http://tool.jz123.cn" target="_blank">第五个广告代码</a></div> <div> <a href="http://alexa.jz123.cn" target="_blank">第六个广告代码</a></div> </div> <div style="display:none;width=0;height=0"> <script> <!-- function startmarquee(height,delay) { var p=false; var piikee=document.getElementById("marqueebox"); var orz123=piikee.getElementsByTagName("div"); var divcount =orz123.length -1 ; piikee.onmouseover=function(){p=true;} piikee.onmouseout=function(){p=false;} piikee.scrollTop = 0; function start() { t=setInterval(scrolling,delay); if(piikee.scrollTop >= height*divcount) { piikee.scrollTop = 0 ; } else { if(!p) { piikee.scrollTop += height;
} } }
function scrolling() { clearInterval(t); setTimeout(start,delay); } setTimeout(start,delay); }
startmarquee(22,1000); //startmarquee(一次滚动高度,每次停留时间) 注意你div中广告高度多少这里就设置多少
//--> </script> </div> </body> </html>
|
广告代码2 第二份顺序上滚(div隐藏方法):
<html> <head> <STYLE type=text/css>BODY {MARGIN-TOP: 0px; MARGIN-LEFT: 0px ;MARGIN-BOTTOM: 0px; MARGIN-RIGHT: 0px}</STYLE> </head> <body> <div id="msgBox" onMouseOver="myStop();" onMouseOut="myStart()"> <div> <a href="http://www.bankcha.com" target="_blank">第一个广告代码</a></div> <div > <a href="http://www.tianqila.com" target="_blank">第二个广告代码</a></div> <div > <a href="http://www.huocheshike.cn" target="_blank">第三个广告代码</a></div> <div > <a href="http://www.jz123.cn" target="_blank">第四个广告代码</a></div> <div > <a href="http://www.0491.com" target="_blank">第五个广告代码</a></div> <div > <a href="http://tool.jz123.cn" target="_blank">第六个广告代码</a></div> </div> <script> <!--
var delay; var b = 0; var t = null; var flag = true; var piikee = document.getElementById("msgBox"); var orz123 = piikee.getElementsByTagName("div"); var divCount = orz123.length; for(var i=0;i<divCount;i++) { orz123[i].style.display="none"; } function scrollNew(delay) { t = setInterval(startScroll,delay); function startScroll() { if(b==divCount) { orz123[b-1].style.display="none"; b=0; } if(flag) { if(b>0) orz123[b-1].style.display="none"; orz123[b].style.display = "block"; b++; } }
} function myStop() { flag=false; }
function myStart() { flag=true; } scrollNew(1000); </script> </body> </html>
|
上一篇:javascript阻止事件冒泡和浏览器的默认行为 下一篇:JS中数组的操作