图片循环问题!请各位大虾帮帮忙,急啊!!!!!!

请输入... 2008-05-30 02:15:14
当我把JSP11.jsp,与JSP12.jsp放在同一个页面时,JSP12.jsp里的循环图片就只能循环3张,单独放时JSP12.jsp里的循环图片就可以全部循环,我认为是受JSP11.jsp里的setTimeout影响了,我想了好久都没有改出来,请各位大虾帮帮忙,分不够我可以在加


JSP1.jsp

<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
jsp6
</title>
</head>
<body bgcolor="#ffffff">

<jsp:include flush="" page="jsp10.jsp" />
<jsp:include flush="" page="jsp11.jsp" />


</form>
</body>
</html>
JSP10.jsp

<%@ page contentType="text/html; charset=GBK" %>


<script>
var bannerAD = new Array();
var bannerADlink = new Array();
var bannerADinfo = new Array();
var adNum = -1;


bannerAD[0] ="CAL7GGGRXC/right_11.gif" ;
bannerADlink[0] = "N9O9IGPb2E.jsp?Id=B000000281" ;
bannerADinfo[0] = "aaaaaaaaa";

bannerAD[1] = "CAL7GGGRXC/logo1.jpg";
bannerADlink[1] = "http://10.0.2.9/info/list.jsp?Id=B000000200";
bannerADinfo[1] = "bbbbbbb";


function nextAd(){

if (adNum != -1) clearTimeout(theTimer);
if(adNum<bannerAD.length-1)adNum++ ;
else adNum=0;
document.all.bannerpic.src = bannerAD[adNum];

ele = document.getElementById("p"+eval(adNum));
clearbg();
ele.bgColor="red";
theTimer=setTimeout("nextAd()", 15000);

}

function cAd(){

ele = document.getElementById("p"+eval(adNum));
clearbg();
ele.bgColor="red";
theTimer2=setTimeout("cAd()", 1000);
}

function clearbg()
{
for (i=0;i<bannerAD.length;i++)document.getElementById("p"+eval(i)).bgColor="";
}

function jump2url()
{
jumpUrl=bannerADlink[adNum];
jumpTarget="_blank";
if (jumpUrl != '') {
if (jumpTarget != '')window.open(jumpUrl,jumpTarget);
else location.href=jumpUrl;
}
}
</script>

<table cellspacing=1 cellpadding=0 width=770 align=center border=0 style=font-size:12px>
<tr><td valign=top align=right >
<img id="bannerpic" src="#" onclick="jump2url()" style="cursor:hand;width:770px;height:70px border=0"><br>
<table cellspacing=1 cellpadding=0 style="position:relative;font-size:14px;font-family:Arial;font-weight:bold;color:white;cursor:hand;FILTER:Alpha(Opacity=50);top:-16px" bgcolor=white border=0>
<tr bgcolor=black >



<script>
{
for (k=0;k<bannerAD.length;k++)
{
prek = k - 1;
if (k==-1){prek=bannerAD.length;}
document.write("<td width='30px' height='5px' id=p"+eval(k)+" align='center' onclick=\"adNum='"+eval(prek)+"';clearTimeout(theTimer);nextAd()\" valign=top><a title='"+bannerADinfo[k]+"'>"+eval(k+1)+"<br></a>")
}
}
</script>

</tr>
</table>
</table>
<script>
{
nextAd();
cAd();
}
</script>

jsp11.jsp


<%@ page contentType="text/html; charset=GBK" %>

<script language="JavaScript1.2">

var scrollerwidth='300px'
var scrollerheight='250px'
var scrollerbgcolor='white'

var pausebetweenimages=1000


var slideimages=new Array()
slideimages[0]='<img src=CAL7GGGRXC/2008052602.jpg width=280 height=210><br><table width=300><tr><td align=center>1 </td></tr></table>'
slideimages[1]='<img src=CAL7GGGRXC/2008052601.jpg width=280 height=210><br><table width=300><tr><td align=center>2</td></tr></table>'
slideimages[2]='<img src=CAL7GGGRXC/2008052301.jpg width=280 height=210><br><table width=300><tr><td align=center>3</td></tr></table>'
slideimages[3]='<img src=CAL7GGGRXC/2008011702.jpg width=280 height=210><br><table width=300><tr><td align=center>4</td></tr></table>'
slideimages[4]='<img src=../../info/RMKALSGK8V/a01.jpg width=280 height=210><br><table width=300><tr><td align=center>5</td></tr></table>'
slideimages[5]='<img src=../../info/RMKALSGK8V/a02.jpg width=280 height=210><br><table width=300><tr><td align=center>6</td></tr></table>'
slideimages[6]='<img src=../../info/RMKALSGK8V/a03.jpg width=280 height=210><br><table width=300><tr><td align=center>7</td></tr></table>'
slideimages[7]='<img src=../../info/RMKALSGK8V/a04.jpg width=280 height=210><br><table width=300><tr><td align=center>8</td></tr></table>'
slideimages[8]='<img src=../../info/RMKALSGK8V/a05.jpg width=280 height=210><br><table width=300><tr><td align=center>9</td></tr></table>'



var ie=document.all
var dom=document.getElementById
if (slideimages.length>1)
i=2
else
i=0
function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.left>0&&tlayer.left<=5){
tlayer.left=0
setTimeout("move1(tlayer)",pausebetweenimages)
setTimeout("move2(document.main.document.second)",pausebetweenimages)
return
}
if (tlayer.left>=tlayer.document.width*-1){
tlayer.left-=5
setTimeout("move1(tlayer)",50)
}
else{
tlayer.left=parseInt(scrollerwidth)+5
tlayer.document.write(slideimages[i])
tlayer.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
}
function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.left>0&&tlayer2.left<=5){
tlayer2.left=0
setTimeout("move2(tlayer2)",pausebetweenimages)
setTimeout("move1(document.main.document.first)",pausebetweenimages)
return
}
if (tlayer2.left>=tlayer2.document.width*-1){
tlayer2.left-=5
setTimeout("move2(tlayer2)",50)
}
else{
tlayer2.left=parseInt(scrollerwidth)+5
tlayer2.document.write(slideimages[i])
tlayer2.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}
}
function move3(whichdiv){
tdiv=eval(whichdiv)
if (parseInt(tdiv.style.left)>0&&parseInt(tdiv.style.left)<=5){
tdiv.style.left=0+"px"
setTimeout("move3(tdiv)",pausebetweenimages)
setTimeout("move4(scrollerdiv2)",pausebetweenimages)
return
}
if (parseInt(tdiv.style.left)>=tdiv.offsetWidth*-1){
tdiv.style.left=parseInt(tdiv.style.left)-5+"px"
setTimeout("move3(tdiv)",50)
}
else{
tdiv.style.left=scrollerwidth
tdiv.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}
function move4(whichdiv){
tdiv2=eval(whichdiv)
if (parseInt(tdiv2.style.left)>0&&parseInt(tdiv2.style.left)<=5){
tdiv2.style.left=0+"px"
setTimeout("move4(tdiv2)",pausebetweenimages)
setTimeout("move3(scrollerdiv1)",pausebetweenimages)
return
}
if (parseInt(tdiv2.style.left)>=tdiv2.offsetWidth*-1){
tdiv2.style.left=parseInt(tdiv2.style.left)-5+"px"
setTimeout("move4(scrollerdiv2)",50)
}
else{
tdiv2.style.left=scrollerwidth
tdiv2.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}
function startscroll(){
if (ie||dom){
scrollerdiv1=ie? first2 : document.getElementById("first2")
scrollerdiv2=ie? second2 : document.getElementById("second2")
move3(scrollerdiv1)
scrollerdiv2.style.left=scrollerwidth
}
else if (document.layers){
document.main.visibility='show'
move1(document.main.document.first)
document.main.document.second.left=parseInt(scrollerwidth)+5
document.main.document.second.visibility='show'
}
}
window.onload=startscroll
</script>
<ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}; visibility=hide>
<layer id="first" left=1 top=0 width=&{scrollerwidth}; >
<script language="JavaScript1.2">
if (document.layers)
document.write(slideimages[0])
</script>
</layer>
<layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
<script language="JavaScript1.2">
if (document.layers)
document.write(slideimages[1])
</script>
</layer>
</ilayer>
<script language="JavaScript1.2">
if (ie||dom){
document.writeln('<div id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;background-color:'+scrollerbgcolor+'">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:1px;top:0px;">')
document.write(slideimages[0])
document.writeln('</div>')
document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px">')
document.write(slideimages[1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</div>')
}
</script>



...全文
134 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
goldlive_8888 2008-06-02
  • 打赏
  • 举报
回复
你可以在某些地方用alert(),看看变量的值是什么
请输入... 2008-06-02
  • 打赏
  • 举报
回复
我没有看出来字段有冲突,请各位帮忙调试一下,我在ie和firefox都测试了的,这个代码一粘过去就可以看到效果的,但图片3时就只循环3那张图片了,后面其实的显示不出来
sportq 2008-06-02
  • 打赏
  • 举报
回复
运行的时候看下PAGE 信息有没有报错 如果报错 肯定是JS 如果没报错那就是页面中有字段冲突
showgood119 2008-06-02
  • 打赏
  • 举报
回复
关注ing
BD_zhu 2008-06-02
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 dyw31415926 的回复:]
太长了,不想看,不过根据经验,首先应该考虑js出错了,或是js逻辑有问题,

注意的是ie下测试,有时明明js出错了也不见提示异常了,请用ie和firefox各测试一次!
[/Quote]
完全同意
请输入... 2008-06-02
  • 打赏
  • 举报
回复
没有办法啊,这两个页面一个循环滚动,一个定时换图片如果是单独放的话不会出现任何问题,但是要求是这两个都要有,JS代码,我看也没有说那里出错过请各位帮忙看看,其实分开看时这个代码也不长的
dyw31415926 2008-06-02
  • 打赏
  • 举报
回复
找点可能出错的代码出来:
JSP1.jsp

<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
jsp6
</title>
</head>
<body bgcolor="#ffffff">

<jsp:include flush="" page="jsp10.jsp" />
<jsp:include flush="" page="jsp11.jsp" />


</form>这个是多余的吧
</body>
</html>


2 <script> <script language="JavaScript1.2"> 每写一次换一种花样?
用<script type="text/javascript">

3 在jsp10.jsp jsp11.jsp中, 变量i竟然是个全局变量,是一定有问题的,两边都换个有意思的名字吧,
记得,即使是全局变量,也声明一下!

4 if (ie ¦ ¦dom){
这个是啥玩意???
yyandlh 2008-05-30
  • 打赏
  • 举报
回复
这么多代码没心思看去...
super_zwj 2008-05-30
  • 打赏
  • 举报
回复
关于定时器的使用你再仔细看看其用法,请不要再函数自身内定时执行该函数!
super_zwj 2008-05-30
  • 打赏
  • 举报
回复
另外可以很明确的告诉你
function nextAd(){

if (adNum != -1) clearTimeout(theTimer);
if(adNum <bannerAD.length-1)adNum++ ;
else adNum=0;
document.all.bannerpic.src = bannerAD[adNum];

ele = document.getElementById("p"+eval(adNum));
clearbg();
ele.bgColor="red";
theTimer=setTimeout("nextAd()", 15000);

}
将很可能造成无限循环,你的js写的很不好!
dyw31415926 2008-05-30
  • 打赏
  • 举报
回复
太长了,不想看,不过根据经验,首先应该考虑js出错了,或是js逻辑有问题,

注意的是ie下测试,有时明明js出错了也不见提示异常了,请用ie和firefox各测试一次!
super_zwj 2008-05-30
  • 打赏
  • 举报
回复
可以明确的是你的2个页面里肯定存在js对象冲突问题!
grapepaul 2008-05-30
  • 打赏
  • 举报
回复
建议找有经验的同事问问!
请输入... 2008-05-30
  • 打赏
  • 举报
回复
我调了很久,没有调好,JS没有出错,就是两个页面放在一起时,引起只能循环到第三张,应该是JSP10.JSP,与JSP11.JSP,两个分开放时不会出现任何问题的
super_zwj 2008-05-30
  • 打赏
  • 举报
回复
这是你的js问题,不知道你循环到第三张不能循环时浏览器报什么错误没?建议你调试js代码,问题应该很好发现的!
lydiablo 2008-05-30
  • 打赏
  • 举报
回复
代码好长没精力看,绑定啊
xiaoqiangcn 2008-05-30
  • 打赏
  • 举报
回复
顶~~~~~下~~~`
jdlsfl 2008-05-30
  • 打赏
  • 举报
回复
帮顶,机器不能调试
你想当“李逍遥”式的“大侠”吗? 这里无需计算机基础,无需编程经验,你也不必是计算机专业的在校大学生....只要爱好游戏,怀揣梦想! 有一定自主学习能力,跟着刘老师从“编程小白”修炼为游戏研发“大虾”吧!!!学习好Unity,其先决条件是一定要有稳固、扎实的编程基础!课程 《C# For Unity系列之入门篇》配套学习资料链接:http://pan.baidu.com/s/1gflxreN 密码:sou5;刘老师讲Unity学员群(2) 497429806一、热更新系列(技术含量:中高级):A:《lua热更新技术中级篇》https://edu.csdn.net/course/detail/27087B:《热更新框架设计之Xlua基础视频课程》https://edu.csdn.net/course/detail/27110C:《热更新框架设计之热更流程与热补丁技术》https://edu.csdn.net/course/detail/27118D:《热更新框架设计之客户端热更框架(上)》https://edu.csdn.net/course/detail/27132E:《热更新框架设计之客户端热更框架(中)》https://edu.csdn.net/course/detail/27135F:《热更新框架设计之客户端热更框架(下)》https://edu.csdn.net/course/detail/27136二:框架设计系列(技术含量:中级): A:《游戏UI界面框架设计系列视频课程》https://edu.csdn.net/course/detail/27142B:《Unity客户端框架设计PureMVC篇视频课程(上)》https://edu.csdn.net/course/detail/27172C:《Unity客户端框架设计PureMVC篇视频课程(下)》https://edu.csdn.net/course/detail/27173D:《AssetBundle框架设计_框架篇视频课程》https://edu.csdn.net/course/detail/27169三、Unity脚本从入门到精通(技术含量:初级)A:《C# For Unity系列之入门篇》https://edu.csdn.net/course/detail/4560B:《C# For Unity系列之基础篇》https://edu.csdn.net/course/detail/4595C: 《C# For Unity系列之中级篇》https://edu.csdn.net/course/detail/24422D:《C# For Unity系列之进阶篇》https://edu.csdn.net/course/detail/24465四、虚拟现实(VR)与增强现实(AR):(技术含量:初级)A:《虚拟现实之汽车仿真模拟系统 》https://edu.csdn.net/course/detail/26618五、Unity基础课程系列(技术含量:初级) A:《台球游戏与FlappyBirds—Unity快速入门系列视频课程(第1部)》 https://edu.csdn.net/course/detail/24643B:《太空射击与移动端发布技术-Unity快速入门系列视频课程(第2部)》https://edu.csdn.net/course/detail/24645 C:《Unity ECS(二) 小试牛刀》https://edu.csdn.net/course/detail/27096六、Unity ARPG课程(技术含量:初中级):A:《MMOARPG地下守护神_单机版实战视频课程(上部)》https://edu.csdn.net/course/detail/24965B:《MMOARPG地下守护神_单机版实战视频课程(中部)》https://edu.csdn.net/course/detail/24968C:《MMOARPG地下守护神_单机版实战视频课程(下部)》https://edu.csdn.net/course/detail/24979

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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