首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库 | 站长工具
会员投稿 投稿指南 RSS订阅
当前位置:主页>网络编程>Javascript教程>资讯:JS实现广告顺序轮播和随机轮播四份代码

JS实现广告顺序轮播和随机轮播四份代码

www.jz123.cn  2010-09-27   来源:   中国建站    责任编辑(袁袁)    我要投递新闻

  广告代码3 第三份随机上滚(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="marqueebox" style="margin-top:0px;width:369px;height:22px;float:left;line-height:22px;text-align:top;overflow:hidden ">
<div>&nbsp;<a href="http://www.bankcha.com" target="_blank">第一个广告代码</a></div>
<div>&nbsp;<a href="http://www.tianqila.com" target="_blank">第二个广告代码</a></div>
<div>&nbsp;<a href="http://www.huocheshike.cn" target="_blank">第三个广告代码</a></div> 
<div>&nbsp;<a href="http://www.jz123.cn" target="_blank">第四个广告代码</a></div>
<div> &nbsp;<a href="http://www.yayatu.com" target="_blank">第五个广告代码</a></div>
<div>&nbsp;<a href="http://myjs.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 = Math.round( Math.random() * divcount)* height;
function start()
{
  t=setInterval(scrolling,delay);
  
if(!p)
  {
  piikee.scrollTop = Math.round( Math.random() * divcount)* height;
  
  }
  
}

function scrolling()
  {
  clearInterval(t);
  setTimeout(start,delay);
  }          
  setTimeout(start,delay);
}
   startmarquee(22,1000);  //startmarquee(一次滚动高度,每次停留时间) 注意你div中广告高度多少这里就设置多少滚动高度
//-->
</script>
  </div>
</body>
</html>

    广告代码4:第四份随机上滚(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>&nbsp;<a href="http://www.bankcha.com" target="_blank">第一个广告代码</a></div>
<div >&nbsp;<a href="http://www.jz123.cn" target="_blank">第二个广告代码</a></div>
<div  >&nbsp;<a href="http://www.wozuan.com" target="_blank">第三个广告代码</a></div> 
<div  >&nbsp;<a href="http://www.tianqila.com" target="_blank">第四个广告代码</a></div>
<div   > &nbsp;<a href="http://www.huocheshike.cn" target="_blank">第五个广告代码</a></div>
<div  >&nbsp;<a href="http://www.yayatu.com" 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(flag)
  {    
        orz123[b].style.display="none";
       
      b = Math.round( Math.random() * (divCount-1));
     
        orz123[b].style.display="block";
    }
    }
  }
 
  function myStop()
  {
    flag=false;
  }
  function myStart()
  {
    flag=true;
  }
  scrollNew(1000);
</script>
</body>
</html>

 

上一篇:javascript阻止事件冒泡和浏览器的默认行为 下一篇:JS中数组的操作

评论总数:0 [ 查看全部 ] 网友评论


关于我们隐私版权广告服务友情链接联系我们网站地图