用JavaScript实现repeat 循环添加操作

原创 2006年06月16日 16:20:00

演示效果:http://www.webjx.com/htmldata/2005-11-26/test.html

<script LANGUAGE="javascript">
<!--
var cpAD=new Array();
var cpADlink=new Array();
var cpADmsg=new Array();
//定义了5个数组
var adNum=5;
var coll=0;

//ad/1.html 那时你链接的广告地址

cpAD[0]="banners/mba.gif";
cpADlink[0]="ad/1.html";
cpADmsg[0]="1";

cpAD[1]="banners/google.gif";
cpADlink[1]="ad/2.html"
cpADmsg[1]="2";

cpAD[2]="banners/2005.gif";
cpADlink[2]="ad/3.html";
cpADmsg[2]="3";

cpAD[3]="banners/cz8y.gif";
cpADlink[3]="ad/4.html";
cpADmsg[3]="4";

cpAD[4]="banners/JG_YUEDU.gif";
cpADlink[4]="ad/5.html";
cpADmsg[4]="5";

var preloadedimages=new Array();
for (i=1;i<cpAD.length;i++){
preloadedimages[i]=new Image();
preloadedimages[i].src=cpAD[i];
}

//跳转的URL地址
function jump2url()
{
jumpUrl=cpADlink[adNum];
jumpTarget='_blank';
if (jumpUrl != '')
{
        if (jumpTarget != '')
                window.open(jumpUrl,jumpTarget);
        else location.href=jumpUrl;
        }
}

//图片变化的函数
function changeimg(n)
{
        adNum=n;
        switch(adNum)
        {
        case 0:
        {
                window.img1.src="banners/1-2.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5.gif";
                break;
        }
        case 1:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2-2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5.gif";
                break;
        }
        case 2:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3-2.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5.gif";
                break;
        }
                case 3:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4-2.gif";
                window.img5.src="banners/5.gif";
                break;
        }
                case 4:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5-2.gif";
                break;
        }
        }
        window.clearInterval(theTimer);
        adNum=adNum-1;
        nextAd();
}
//当点击时直接跳转
function nextAd(){
coll++;
if(coll>1)
{
switch(adNum+1)
{
        case 5:
        {
                window.img1.src="banners/1-2.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5.gif";
                break;
        }
        case 1:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2-2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5.gif";
                break;
        }
        case 2:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3-2.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5.gif";
                break;
        }
        case 3:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4-2.gif";
                window.img5.src="banners/5.gif";
                break;
        }
    case 4:
        {
                window.img1.src="banners/1.gif";
                window.img2.src="banners/2.gif";
                window.img3.src="banners/3.gif";
                window.img4.src="banners/4.gif";
                window.img5.src="banners/5-2.gif";
                break;
        }
}
}
if(adNum<cpAD.length-1)adNum++ ;
else adNum=0;
setTransition();
document.images.cpADrush.src=cpAD[adNum];
playTransition();
displayStatusMsg();
//定义了轮换时间 5s
theTimer=setTimeout("nextAd()", 5000);
}

function setTransition(){
if (document.all){
cpADrush.filters.revealTrans.Transition=23;
cpADrush.filters.revealTrans.apply();
}

}
function playTransition(){
if (document.all)
cpADrush.filters.revealTrans.play()
}
function displayStatusMsg() {
status=cpADmsg[adNum];
document.returnValue = true;
}
//结束
// -->

</script>

 

<table height="148" cellspacing="0" cellpadding="0">
              <tr>
                <td> <a href="javascript:jump2url()"> <img style="FILTER: revealTrans(duration=2,transition=23)" height="150" src width="575" border="0" name="cpADrush"></a></td>
                <script language="JavaScript">nextAd()</script>
              </tr>
              <tr>
                <td>
                  <table width="575"  name="T1" id="T1" border="0" cellspacing="1" cellpadding="0">
                    <tr>
                      <td align="right"><img src="banners/dh_bg.gif" width="178" height="16"></td>
                      <td width="20"><a href="#" onMouseOver="changeimg(0)"><img name="Image2"  id="img1" border="0" src="banners/1.gif" width="20" height="16" onClick="changeimg(0)"></a></td>
                      <td width="20"><a href="#" onMouseOver="changeimg(1)"><img name="Image3" id="img2" border="0" src="banners/2.gif" width="20" height="16" onClick="changeimg(1)"></a></td>
                      <td width="20"><a href="#" onMouseOver="changeimg(2)"><img name="Image4" id="img3" border="0" src="banners/3.gif" width="20" height="16" onClick="changeimg(2)"></a></td>
                      <td width="20"><a href="#" onMouseOver="changeimg(3)"><img name="Image5" id="img4" border="0" src="banners/4.gif" width="20" height="16" onClick="changeimg(3)"></a></td>
                      <td width="20"><a href="#" onMouseOver="changeimg(4)"><img name="Image6" id="img5" border="0" src="banners/5.gif" width="20" height="16" onClick="changeimg(4)"></a></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Javascript实现能够双端操作的循环队列

队列在数据结构家族里的地位是举足轻重的。传统的队列一般在队头进行出队操作,在队尾进行入队操作,而双端循环队列是功能最为齐全的,它有四个操作:A.在队头出队 B.在队头入队 C.在队尾出队 D.在队尾入...

Swift-(do/repeat)while循环

1. while循环 OC的 while 循环格式:while(循环保持条件){需要执行的语句} 如果只有一条指令while后面的大括号可以省略 条件语句判断非零即真 swift的 while 循环w...

R语言︱函数使用技巧(循环、if族/for、switch、repeat、ifelse、stopifnot)

1、循环 ##循环for iris allzl=unique(iris$setosa) for (i in 1:2){ pp=iris[iris$setosa==allzl[i],] plot...

InfoPath中重复表的操作+repeat+table+operation

loop through items in a repeating table in InfoPath 2007   http://www.bizsupportonline.net/infopat...

AngularJS ng-repeat嵌套循环中,如何取得外层循环的索引值

下面,笔者给大家提供一种讨巧的方法来实现

mysql while,loop,repeat循环,符合条件跳出循环

1、while循环 DELIMITER $$ DROP PROCEDURE IF EXISTS `sp_test_while`$$ CREATE PROCEDURE `sp_test_while`...

《iOS移动开发从入门到精通》图书连载13:for循环、while循环语句、repeat-while循环语句

3.3  循环语句和条件判断语句3.3.1  for循环Swift 的for循环语句,可以用来重复执行一系列语句,直到达成特定的条件。Swift提供了两种for循环语句,一种是C语言风格的for循环:...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)