做网页的高手来帮忙啊 现在网页里常见的图片公告

JavaScript022

做网页的高手来帮忙啊 现在网页里常见的图片公告,第1张

可以是FLASH做,也可以用JS实现

下面是JS实现的

==========================================以下保存为ad.js文件

var cpAD=new Array()

var cpADlink=new Array()

var cpADmsg=new Array()

var adNum=5//定义了5个数组

var coll=0

cpAD[0]="upimg/p1.gif"//链接图片

cpADlink[0]="http://www.flywe.net/"//链接URL

cpADmsg[0]="Flywe の Blog"//状态栏提示信息

cpAD[1]="upimg/p2.gif"

cpADlink[1]="http://www.flywe.net/"

cpADmsg[1]="Flywe の Blog"

cpAD[2]="upimg/p3.gif"

cpADlink[2]="http://www.flywe.net/"

cpADmsg[2]="Flywe の Blog"

cpAD[3]="upimg/p4.gif"

cpADlink[3]="http://www.flywe.net/"

cpADmsg[3]="Flywe の Blog"

cpAD[4]="upimg/p5.gif"

cpADlink[4]="http://www.flywe.net/"

cpADmsg[4]="Flywe の Blog"

var preloadedimages=new Array()

for (i=1i<cpAD.lengthi++){

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="upimg/1-2.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/5.gif"

break

}

case 1:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2-2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/5.gif"

break

}

case 2:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3-2.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/5.gif"

break

}

case 3:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4-2.gif"

window.img5.src="upimg/5.gif"

break

}

case 4:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/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="upimg/1-2.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/5.gif"

break

}

case 1:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2-2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/5.gif"

break

}

case 2:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3-2.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/5.gif"

break

}

case 3:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4-2.gif"

window.img5.src="upimg/5.gif"

break

}

case 4:

{

window.img1.src="upimg/1.gif"

window.img2.src="upimg/2.gif"

window.img3.src="upimg/3.gif"

window.img4.src="upimg/4.gif"

window.img5.src="upimg/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

}

===========================================以下保存为ad.html

<!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/htmlcharset=gb2312" />

<title>无标题文档</title>

<script language="javascript" src="ad.js"></script>

</head>

<body>

<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="upimg/p_bg.gif" width="178" height="16"></td>

<td width="20"><a href="javascript:" onMouseOver="changeimg(0)"><img name="Image2" id="img1" border="0" src="upimg/1.gif" width="20" height="16" onClick="changeimg(0)"></a></td>

<td width="20"><a href="javascript:" onMouseOver="changeimg(1)"><img name="Image3" id="img2" border="0" src="upimg/2.gif" width="20" height="16" onClick="changeimg(1)"></a></td>

<td width="20"><a href="javascript:" onMouseOver="changeimg(2)"><img name="Image4" id="img3" border="0" src="upimg/3.gif" width="20" height="16" onClick="changeimg(2)"></a></td>

<td width="20"><a href="javascript:" onMouseOver="changeimg(3)"><img name="Image5" id="img4" border="0" src="upimg/4.gif" width="20" height="16" onClick="changeimg(3)"></a></td>

<td width="20"><a href="javascript:" onMouseOver="changeimg(4)"><img name="Image6" id="img5" border="0" src="upimg/5.gif" width="20" height="16" onClick="changeimg(4)"></a></td>

</tr>

</table>

</td>

</tr>

</table>

</body>

</html>

自己新建个文件夹upimg,自己弄几张图片,跟据js文件里的图片文件名和路径改下就可以了