Js做的动态Flash
下面放在js页面
// JScript 文件
// 计时器
var theTimer = null;
var cpAD=new Array();
var cpADlink=new Array();
var cpADmsg=new Array();
var adNum=5; //定义了5个数组
var coll=0;
cpAD[0]="upimg/shouye/p1.jpg"; //链接图片
cpADlink[0]=""; //链接URL
cpADmsg[0]="Flywe の Blog"; //状态栏提示信息
cpAD[1]="upimg/shouye/p2.jpg";
cpADlink[1]=""
cpADmsg[1]="Flywe の Blog";
cpAD[2]="upimg/shouye/p3.jpg";
cpADlink[2]="";
cpADmsg[2]="Flywe の Blog";
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="upimg/1-2.jpg";
// window.img2.src="upimg/2.jpg";
// window.img3.src="upimg/3.jpg";
document.getElementById("img1").src="uping/1-2.jpg";
document.getElementById("img2").src="uping/2.jpg";
document.getElementById("img3").src="uping/3.jpg";
break;
}
case 1:
{
document.getElementById("img1").src="upimg/1.jpg";
document.getElementById("img2").src="upimg/2-2.jpg";
document.getElementById("img3").src="upimg/3.jpg";
break;
}
case 2:
{
document.getElementById("img1").src="upimg/1.jpg";
document.getElementById("img2").src="upimg/2.jpg";
document.getElementById("img3").src="upimg/3-2.jpg";
break;
}
}
window.clearInterval(theTimer);
adNum=adNum-1;
nextAd();
}
//当点击时直接跳转
function nextAd()
{
coll++;
if(coll>1)
{
switch(adNum+1)
{
case 3:
{
document.getElementById("img1").src = "upimg/1-2.jpg";
document.getElementById("img2").src="upimg/2.jpg";
document.getElementById("img3").src="upimg/3.jpg";
break;
}
case 1:
{
document.getElementById("img1").src="upimg/1.jpg";
document.getElementById("img2").src="upimg/2-2.jpg";
document.getElementById("img3").src="upimg/3.jpg";
break;
}
case 2:
{
document.getElementById("img1").src="upimg/1.jpg";
document.getElementById("img2").src="upimg/2.jpg";
document.getElementById("img3").src="upimg/3-2.jpg";
break;
}
}
}
if(adNum<cpAD.length-1)adNum++ ;
else adNum=0;
setTransition();
document.getElementById("cpADrush").src=cpAD[adNum];
playTransition();
displayStatusMsg();
//定义了轮换时间 5s
theTimer=setTimeout("nextAd()", 5000);
}
function setTransition(){
if (document.all){
document.getElementById("cpADrush").filters.revealTrans.Transition=23;
document.getElementById("cpADrush").filters.revealTrans.apply();
}
}
function playTransition(){
if (document.all)
document.getElementById("cpADrush").filters.revealTrans.play()
}
function displayStatusMsg() {
status=cpADmsg[adNum];
document.returnValue = true;
}
下面是aspx页面
<table width="688px" height="304px" cellspacing="0" cellpadding="0">
<tr>
<td>
<img style="filter: revealTrans(duration=2,transition=23)" height="304px" width="688px"
border="0" name="cpADrush" alt=""></td>
<script language="JavaScript">nextAd()</script>
</tr>
<tr>
<table width="100%" name="T1" id="T1" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="right" style="width: 660px; height: 16px;">
<!--<img src="../images/furunyisheng2.jpg" width="465" height="16" />-->
</td>
<td style="width: 5px; height: 16px;">
<a href="javascript:;" onmouseover="changeimg(0)">
<img name="Image2" id="img1" border="0" src="upimg/1.jpg" onclick="changeimg(0)"></a></td>
<td width="5px" style="height: 16px">
<a href="javascript:;" onmouseover="changeimg(1)">
<img name="Image3" id="img2" border="0" src="upimg/2.jpg" onclick="changeimg(1)"></a></td>
<td width="5px" style="height: 16px">
<a href="javascript:;" onmouseover="changeimg(2)">
<img name="Image4" id="img3" border="0" src="upimg/3.jpg" onclick="changeimg(2)"></a></td>
</tr>
</table>
</tr>
</table>