[JS代码]用JavaScript实现网页轮换广告效果

转载 2006年06月16日 10:41:00

(http://www.webjx.com/htmldata/2005-11-26/1132968209.html )

演示效果: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实现仿163的js广告向下挤压页面的效果

本次实现一个js小小特效,效果就是广告从页面的上方出来将基本页面挤压下去。 实现的思路是将两个div(广告div1和div2)。将div1的高度不断增加,增加的同时div2的y轴坐标变大,div1的...

JavaScript(07): 实例2---网页广告漂浮效果(面向对象版)

在上一个版本的基础上使用JavaScript的面向对象完成,为了不影响阅读,去掉了随滚动条移动的广告 Example function $(id) { r...

JS实现自定义简单网页软键盘效果代码

自写一个简单点的网页软键盘 * { padding:0; margin:0; } body { background:#fff; } th,

JavaScript js csdn 文字滚动广告效果

转载自: http://blog.csdn.net/ibm_hoojo/article/details/5790372     一、csdn博客中的招聘广告效果:   二、以下是代码实现 ...

JavaScript实现图片的滑动切换效果 的Js代码

/*!  * SlideTrans  * Copyright (c) 2010 cloudgamer  * Blog: http://cloudgamer.cnblogs.com/  * Date: ...

js(JavaScript)代码实现的TAB标签切换效果

一个可以js(JavaScript)的tab标签切换代码,可以自动适应宽度,可以自己添加删除标签块,傻瓜式操作便能完成! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML...

网页右下角JS广告代码

  • 2014-03-05 09:21
  • 34KB
  • 下载

JS网页背投广告代码

  • 2011-04-18 11:21
  • 332KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

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