急,问题处在哪?

牙签是竹子的 2008-04-25 10:10:44
<script language="javascript" type="text/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]="care_img/mba.gif";
cpADlink[0]="ad/1.html";
cpADmsg[0]="1";

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

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

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

cpAD[4]="care_img/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="../images/1-2.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 1:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2-2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 2:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3-2.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 3:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4-2.gif";
window.img5.src="../images/5.gif";
break;
}
case 4:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/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="../images/1-2.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 1:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2-2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 2:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3-2.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 3:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4-2.gif";
window.img5.src="../images/5.gif";
break;
}
case 4:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/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 style="height:124px" cellspacing="0" cellpadding="0">
<tr>
<td style="width:258px"> <a href="javascript:jump2url()"> <img style="filter:revealTrans(duration=2,transition=23)" height="108" src width="258" border="0" name="cpADrush" /></a></td>
<script language="JavaScript" type="text/javascript">nextAd()</script>
</tr>
<tr>
<td>
<table width="175" name="T1" id="T1" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="right"><img src="../images/dh_bg.gif" width="152" height="16"></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(0)"><img name="Image2" id="img1" border="0" src="../images/1.gif" width="20" height="16" onclick="changeimg(0)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(1)"><img name="Image3" id="img2" border="0" src="../images/2.gif" width="20" height="16" onclick="changeimg(1)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(2)"><img name="Image4" id="img3" border="0" src="../images/3.gif" width="20" height="16" onclick="changeimg(2)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(3)"><img name="Image5" id="img4" border="0" src="../images/4.gif" width="20" height="16" onclick="changeimg(3)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(4)"><img name="Image6" id="img5" border="0" src="../images/5.gif" width="20" height="16" onclick="changeimg(4)"></a></td>
</tr>
</table>
</td>
</tr>
</table>


上面的代码实现的是图片的自动切换,在html中一点错误都没有,然后我把它放在一个aspx页面下,老是提示说“cpADrush”未定义?到底该怎么弄?
...全文
130 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
goody9807 2008-04-25
  • 打赏
  • 举报
回复
<table style="height:124px" cellspacing="0" cellpadding="0">
<tr>
<td style="width:258px"> <a href="javascript:jump2url()"> <img style="filter:revealTrans(duration=2,transition=23)" height="108" src width="258" border="0" name="cpADrush" /></a></td>
<script language="JavaScript" type="text/javascript">nextAd()</script>
</tr>
<tr>
<td>
<table width="175" name="T1" id="T1" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="right"><img src="../images/dh_bg.gif" width="152" height="16"></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(0)"><img name="Image2" id="img1" border="0" src="../images/1.gif" width="20" height="16" onclick="changeimg(0)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(1)"><img name="Image3" id="img2" border="0" src="../images/2.gif" width="20" height="16" onclick="changeimg(1)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(2)"><img name="Image4" id="img3" border="0" src="../images/3.gif" width="20" height="16" onclick="changeimg(2)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(3)"><img name="Image5" id="img4" border="0" src="../images/4.gif" width="20" height="16" onclick="changeimg(3)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(4)"><img name="Image6" id="img5" border="0" src="../images/5.gif" width="20" height="16" onclick="changeimg(4)"></a></td>
</tr>
</table>
</td>
</tr>
</table>

把上面的html代码放在js上面
hy_lihuan 2008-04-25
  • 打赏
  • 举报
回复
name="cpADrush" id="cpADrush"
就这么回事
abc83915 2008-04-25
  • 打赏
  • 举报
回复
确实慢了。。越狱出来的。。。回复很麻烦。。接点小分吧
Eddie005 2008-04-25
  • 打赏
  • 举报
回复
<img style="filter:revealTrans(duration=2,transition=23)" height="108" src width="258" border="0" name="cpADrush" id="cpADrush" />

//<script>块要放在</table>后面
</table>

<script language="javascript" type="text/javascript">
<!--
var cpADrush = document.getElementById("cpADrush");
....
.....
suifengnet 2008-04-25
  • 打赏
  • 举报
回复
huo789 2008-04-25
  • 打赏
  • 举报
回复
慢了,LS已经说的很清楚了
lem12 2008-04-25
  • 打赏
  • 举报
回复
1.将
<img style="filter:revealTrans(duration=2,transition=23)" height="108" src width="258" border="0" name="cpADrush" />
将改成id="cpADrush"

2改js 中
cpADrush

document.getElementById("cpADrush")


document.images.cpADrush.src=cpAD[adNum];
改成
document.getElementById("cpADrush").src=cpAD[adNum];
lem12 2008-04-25
  • 打赏
  • 举报
回复


<script language="javascript" type="text/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]="care_img/mba.gif";
cpADlink[0]="ad/1.html";
cpADmsg[0]="1";

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

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

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

cpAD[4]="care_img/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="../images/1-2.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 1:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2-2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 2:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3-2.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 3:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4-2.gif";
window.img5.src="../images/5.gif";
break;
}
case 4:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/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="../images/1-2.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 1:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2-2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 2:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3-2.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5.gif";
break;
}
case 3:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4-2.gif";
window.img5.src="../images/5.gif";
break;
}
case 4:
{
window.img1.src="../images/1.gif";
window.img2.src="../images/2.gif";
window.img3.src="../images/3.gif";
window.img4.src="../images/4.gif";
window.img5.src="../images/5-2.gif";
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.getElementById("cpADrush").returnValue = true;
}
//结束
// -->

</script>

<table style="height:124px" cellspacing="0" cellpadding="0">
<tr>
<td style="width:258px"> <a href="javascript:jump2url()"> <img style="filter:revealTrans(duration=2,transition=23)" height="108" src width="258" border="0" id="cpADrush" /></a></td>
<script language="JavaScript" type="text/javascript">nextAd()</script>
</tr>
<tr>
<td>
<table width="175" name="T1" id="T1" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="right"><img src="../images/dh_bg.gif" width="152" height="16"></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(0)"><img name="Image2" id="img1" border="0" src="../images/1.gif" width="20" height="16" onclick="changeimg(0)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(1)"><img name="Image3" id="img2" border="0" src="../images/2.gif" width="20" height="16" onclick="changeimg(1)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(2)"><img name="Image4" id="img3" border="0" src="../images/3.gif" width="20" height="16" onclick="changeimg(2)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(3)"><img name="Image5" id="img4" border="0" src="../images/4.gif" width="20" height="16" onclick="changeimg(3)"></a></td>
<td style="width:20px"><a href="#" onmouseover="changeimg(4)"><img name="Image6" id="img5" border="0" src="../images/5.gif" width="20" height="16" onclick="changeimg(4)"></a></td>
</tr>
</table>
</td>
</tr>
</table>

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧