高分求图片浏览代码? 我有很多图片,想在一个网页里进行浏览,谁有这方面的代码,请给个 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给楼主点思路,可以这样1,在进入这页面之前把需要的image的url都查询出来,在页面上赋值给js变量,可以考虑用array数组2,image显示那里如下代码: <img src="b.jpg" id="img" /> <a href="javascript:document.getElementById('img').src='a.jpg';">上一张</a> <a href="javascript:document.getElementById('img').src='c.jpg';">下一张</a>3,当然上面只是个例子,具体的业务逻辑就要你自己来实现了 这只要查询下一个ID和上一个ID就行了!yibunengjing 的方法是最常用的 <SCRIPT> var widths=550; var heights=400; var counts=11; var urls =new Array(); img1=new Image ();img1.src='http://two.freejsp.net/wuchao911/nba_img/11.jpg'; img2=new Image ();img2.src='http://two.freejsp.net/wuchao911/nba_img/2.jpg'; img3=new Image ();img3.src='http://two.freejsp.net/wuchao911/nba_img/3.jpg'; img4=new Image ();img4.src='http://two.freejsp.net/wuchao911/nba_img/4.jpg'; img5=new Image ();img5.src='http://two.freejsp.net/wuchao911/nba_img/5.jpg'; img6=new Image ();img6.src='http://two.freejsp.net/wuchao911/nba_img/6.jpg'; img7=new Image ();img7.src='http://two.freejsp.net/wuchao911/nba_img/7.jpg'; img8=new Image ();img8.src='http://two.freejsp.net/wuchao911/nba_img/8.jpg'; img9=new Image ();img9.src='http://two.freejsp.net/wuchao911/nba_img/1.jpg'; img10=new Image ();img10.src='http://two.freejsp.net/wuchao911/nba_img/10.jpg'; img11=new Image ();img11.src='http://two.freejsp.net/wuchao911/nba_img/9.jpg'; //img6=new Image ();img6.src='dazhou.jpg'; urls[1]='http://www.baidu.com'; urls[2]='http://www.google.com'; urls[3]='http://www.265.com.cn'; urls[4]='http://www.sohu.com'; urls[5]='http://www.yahoo.com.cn'; urls[6]='http://www.sina.com.cn'; urls[7]='http://www.tom.com'; urls[8]='http://www.w3school.com.cn'; urls[9]='http://www.java2000.net'; urls[10]='http://pop.pcpop.com'; urls[11]='http://community.csdn.net'; </SCRIPT> <SCRIPT language="javascript"> //src="http://image2.yesky.com/TLimages/include/product/focus1.js" var nn=1; var key=0; function change_img() { if(key==0) { key=1; } else if(document.all) { document.getElementById("pic").filters[0].Apply(); document.getElementById("pic").filters[0].Play(duration=2); } eval('document.getElementById("pic").src=img'+nn+'.src'); eval('document.getElementById("url").href=urls['+nn+']'); eval('document.getElementById("url").target="_blank"'); for (var i=1;i <=counts;i++) { document.getElementById("xxjdjj"+i).className='axx'; } document.getElementById("xxjdjj"+nn).className='bxx'; nn++; if(nn> counts) { nn=1; } tt=setTimeout('change_img()',4000);} function changeimg(n) { nn=n;window.clearInterval(tt);change_img(); } document.write(' <style> '); document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}'); document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}'); document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}'); document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}'); document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}'); document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}'); document.write(' </style> '); document.write(' <div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;"> '); document.write(' <div> <a id="url"> <img id="pic" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /> </a> </div> '); document.write(' <div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;"> '); for(var i=1;i <counts+1;i++) { document.write(' <a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self"> '+i+' </a> '); } document.write(' </div> </div> '); change_img(); </SCRIPT> <script type="text/javascript">// 7 variables to control behavior var Car_Image_Width=140; var Car_Image_Height=225; var Car_Border=true; var Car_Border_Color="white"; var Car_Speed=4; var Car_Direction=true; var Car_NoOfSides=12; // 必须为 4, 6, 8 或 12 Car_Image_Sources=new Array( "shubin.JPG","shubin.JPG", "sss.bmp","sss.bmp", "ss.JPG","ss.JPG", "da.JPG","da.JPG", "binbin.JPG","binbin.JPG", "shubin1.JPG","shubin1.JPG", "shubin2.JPG","shubin2.JPG", "1.JPG","1.JPG", "2.JPG","2.JPG", "3.JPG","3.JPG", "4.JPG","4.JPG", "5.JPG","5.JPG", "6.JPG","6.JPG" ); CW_I = new Array(Car_NoOfSides/2+1); C_ClcW = new Array(Car_NoOfSides/2); C_Coef = new Array(3*Math.PI/2,0,3*Math.PI/2,11*Math.PI/6,Math.PI/6,3*Math.PI/2,7*Math.PI/4,0,Math.PI/4,3*Math.PI/2,5*Math.PI/3,11*Math.PI/6,0,Math.PI/6,Math.PI/3); var C_CoefOf=Car_NoOfSides==4?0:Car_NoOfSides==6?2:Car_NoOfSides==8?5:9; C_Pre_Img=new Array(Car_Image_Sources.length); var C_Angle=Car_Direction?Math.PI/(Car_NoOfSides/2):0,C_CrImg=Car_NoOfSides,C_MaxW,C_TotalW,C_Stppd=false,i,C_LeftOffset,C_HalfNo=Car_NoOfSides/2; function Carousel() { if(document.getElementById){ for(i=0;i<Car_Image_Sources.length;i+=2) { C_Pre_Img[i]=new Image(); C_Pre_Img[i].src=Car_Image_Sources[i]; } C_MaxW=Car_Image_Width/Math.sin(Math.PI/Car_NoOfSides)+C_HalfNo+1; Car_Div=document.getElementById("Carousel"); for(i=0;i<C_HalfNo;i++) { CW_I[i]=document.createElement("img");Car_Div.appendChild(CW_I[i]); CW_I[i].style.position="absolute"; CW_I[i].style.top=0+"px"; CW_I[i].style.height=Car_Image_Height+"px"; if(Car_Border) { CW_I[i].style.borderStyle="solid"; CW_I[i].style.borderWidth=1+"px"; CW_I[i].style.borderColor=Car_Border_Color; } CW_I[i].src=Car_Image_Sources[2*i]; CW_I[i].lnk=Car_Image_Sources[2*i+1]; CW_I[i].onclick=C_LdLnk; CW_I[i].onmouseover=C_Stp; CW_I[i].onmouseout=C_Rstrt; } CarImages() } } function CarImages() { if(!C_Stppd) { C_TotalW=0; for(i=0;i<C_HalfNo;i++) { C_ClcW[i]=Math.round(Math.cos(Math.abs(C_Coef[C_CoefOf+i]+C_Angle))*Car_Image_Width); C_TotalW+=C_ClcW[i]; } C_LeftOffset=(C_MaxW-C_TotalW)/2; for(i=0;i<C_HalfNo;i++) { CW_I[i].style.left=C_LeftOffset+"px"; CW_I[i].style.width=C_ClcW[i]+"px"; C_LeftOffset+=C_ClcW[i]; } C_Angle+=Car_Speed/720*Math.PI*(Car_Direction?-1:1); if((Car_Direction&&C_Angle<=0)||(!Car_Direction&&C_Angle>=Math.PI/C_HalfNo)) { if(C_CrImg==Car_Image_Sources.length)C_CrImg=0; if(Car_Direction) { CW_I[C_HalfNo]=CW_I[0]; for(i=0;i<C_HalfNo;i++)CW_I[i]=CW_I[i+1]; CW_I[C_HalfNo-1].src=Car_Image_Sources[C_CrImg]; CW_I[C_HalfNo-1].lnk=Car_Image_Sources[C_CrImg+1] } else { for(i=C_HalfNo;i>0;i--)CW_I[i]=CW_I[i-1]; CW_I[0]=CW_I[C_HalfNo]; CW_I[0].src=Car_Image_Sources[C_CrImg]; CW_I[0].lnk=Car_Image_Sources[C_CrImg+1]} C_Angle=Car_Direction?Math.PI/C_HalfNo:0;C_CrImg+=2 } } setTimeout("CarImages()",50)} function C_LdLnk() { if(this.lnk)window.location.href=this.lnk; } function C_Stp() { this.style.cursor=this.lnk?"pointer":"default"; C_Stppd=true; } function C_Rstrt() { C_Stppd=false; }</script><div id="Carousel" style="position:relative"> <img src="photo/200310171/placeholder.gif" width="371" height="225"></div><body onload="Carousel()">更换其中的图片 Car_Image_Sources=new Array( "shubin.JPG","shubin.JPG", "sss.bmp","sss.bmp", "ss.JPG","ss.JPG", "da.JPG","da.JPG", "binbin.JPG","binbin.JPG", "shubin1.JPG","shubin1.JPG", "shubin2.JPG","shubin2.JPG", "1.JPG","1.JPG", "2.JPG","2.JPG", "3.JPG","3.JPG", "4.JPG","4.JPG", "5.JPG","5.JPG", "6.JPG","6.JPG" ); 注意 每张图片需要注入2次 这是网上的一个代码 以前看过 嘿嘿 JSP图片上传 ssh救命啊 求助:如何架构J2EE电子商务系统(WEB系统) 关于portlet的一段代码 连接MYSQL报错。。。。。。高手们给看看 如何实现,每次重启tomcat后ie页面就能自动刷新一下 JSP问题! 项目中开发人员的责任和注意的要点? SpringMVC用progressListener做文件上传进度条时,servletFileUpload.parseRequest(request);返回空值 Spring boot + mybatis 日期的问题 JDBC中添加 请问在java中CLASS如何获得application对象?
1,在进入这页面之前把需要的image的url都查询出来,在页面上赋值给js变量,可以考虑用array数组
2,image显示那里如下代码:
<img src="b.jpg" id="img" />
<a href="javascript:document.getElementById('img').src='a.jpg';">上一张</a>
<a href="javascript:document.getElementById('img').src='c.jpg';">下一张</a>
3,当然上面只是个例子,具体的业务逻辑就要你自己来实现了
var widths=550;
var heights=400;
var counts=11;
var urls =new Array();
img1=new Image ();img1.src='http://two.freejsp.net/wuchao911/nba_img/11.jpg';
img2=new Image ();img2.src='http://two.freejsp.net/wuchao911/nba_img/2.jpg';
img3=new Image ();img3.src='http://two.freejsp.net/wuchao911/nba_img/3.jpg';
img4=new Image ();img4.src='http://two.freejsp.net/wuchao911/nba_img/4.jpg';
img5=new Image ();img5.src='http://two.freejsp.net/wuchao911/nba_img/5.jpg';
img6=new Image ();img6.src='http://two.freejsp.net/wuchao911/nba_img/6.jpg';
img7=new Image ();img7.src='http://two.freejsp.net/wuchao911/nba_img/7.jpg';
img8=new Image ();img8.src='http://two.freejsp.net/wuchao911/nba_img/8.jpg';
img9=new Image ();img9.src='http://two.freejsp.net/wuchao911/nba_img/1.jpg';
img10=new Image ();img10.src='http://two.freejsp.net/wuchao911/nba_img/10.jpg';
img11=new Image ();img11.src='http://two.freejsp.net/wuchao911/nba_img/9.jpg';
//img6=new Image ();img6.src='dazhou.jpg';
urls[1]='http://www.baidu.com';
urls[2]='http://www.google.com';
urls[3]='http://www.265.com.cn';
urls[4]='http://www.sohu.com';
urls[5]='http://www.yahoo.com.cn';
urls[6]='http://www.sina.com.cn';
urls[7]='http://www.tom.com';
urls[8]='http://www.w3school.com.cn';
urls[9]='http://www.java2000.net';
urls[10]='http://pop.pcpop.com';
urls[11]='http://community.csdn.net';
</SCRIPT>
<SCRIPT language="javascript"> //src="http://image2.yesky.com/TLimages/include/product/focus1.js"
var nn=1;
var key=0;
function change_img()
{
if(key==0)
{
key=1;
}
else if(document.all)
{
document.getElementById("pic").filters[0].Apply();
document.getElementById("pic").filters[0].Play(duration=2);
}
eval('document.getElementById("pic").src=img'+nn+'.src');
eval('document.getElementById("url").href=urls['+nn+']');
eval('document.getElementById("url").target="_blank"');
for (var i=1;i <=counts;i++)
{
document.getElementById("xxjdjj"+i).className='axx';
}
document.getElementById("xxjdjj"+nn).className='bxx';
nn++;
if(nn> counts)
{
nn=1;
}
tt=setTimeout('change_img()',4000);} function changeimg(n)
{
nn=n;window.clearInterval(tt);change_img();
}
document.write(' <style> ');
document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}');
document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}');
document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}');
document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
document.write(' </style> ');
document.write(' <div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;"> ');
document.write(' <div> <a id="url"> <img id="pic" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /> </a> </div> ');
document.write(' <div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;"> ');
for(var i=1;i <counts+1;i++)
{
document.write(' <a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self"> '+i+' </a> ');
}
document.write(' </div> </div> ');
change_img(); </SCRIPT>
// 7 variables to control behavior
var Car_Image_Width=140;
var Car_Image_Height=225;
var Car_Border=true;
var Car_Border_Color="white";
var Car_Speed=4;
var Car_Direction=true;
var Car_NoOfSides=12; // 必须为 4, 6, 8 或 12 Car_Image_Sources=new Array(
"shubin.JPG","shubin.JPG",
"sss.bmp","sss.bmp",
"ss.JPG","ss.JPG",
"da.JPG","da.JPG",
"binbin.JPG","binbin.JPG",
"shubin1.JPG","shubin1.JPG",
"shubin2.JPG","shubin2.JPG",
"1.JPG","1.JPG",
"2.JPG","2.JPG",
"3.JPG","3.JPG",
"4.JPG","4.JPG",
"5.JPG","5.JPG",
"6.JPG","6.JPG"
);
CW_I = new Array(Car_NoOfSides/2+1);
C_ClcW = new Array(Car_NoOfSides/2);
C_Coef = new Array(3*Math.PI/2,0,3*Math.PI/2,11*Math.PI/6,Math.PI/6,3*Math.PI/2,7*Math.PI/4,0,Math.PI/4,3*Math.PI/2,5*Math.PI/3,11*Math.PI/6,0,Math.PI/6,Math.PI/3);
var C_CoefOf=Car_NoOfSides==4?0:Car_NoOfSides==6?2:Car_NoOfSides==8?5:9;
C_Pre_Img=new Array(Car_Image_Sources.length);
var C_Angle=Car_Direction?Math.PI/(Car_NoOfSides/2):0,C_CrImg=Car_NoOfSides,C_MaxW,C_TotalW,C_Stppd=false,i,C_LeftOffset,C_HalfNo=Car_NoOfSides/2; function Carousel()
{
if(document.getElementById){
for(i=0;i<Car_Image_Sources.length;i+=2)
{
C_Pre_Img[i]=new Image();
C_Pre_Img[i].src=Car_Image_Sources[i];
}
C_MaxW=Car_Image_Width/Math.sin(Math.PI/Car_NoOfSides)+C_HalfNo+1;
Car_Div=document.getElementById("Carousel");
for(i=0;i<C_HalfNo;i++)
{
CW_I[i]=document.createElement("img");Car_Div.appendChild(CW_I[i]);
CW_I[i].style.position="absolute";
CW_I[i].style.top=0+"px";
CW_I[i].style.height=Car_Image_Height+"px";
if(Car_Border)
{
CW_I[i].style.borderStyle="solid";
CW_I[i].style.borderWidth=1+"px";
CW_I[i].style.borderColor=Car_Border_Color;
}
CW_I[i].src=Car_Image_Sources[2*i];
CW_I[i].lnk=Car_Image_Sources[2*i+1];
CW_I[i].onclick=C_LdLnk;
CW_I[i].onmouseover=C_Stp;
CW_I[i].onmouseout=C_Rstrt;
}
CarImages()
}
} function CarImages()
{
if(!C_Stppd)
{
C_TotalW=0;
for(i=0;i<C_HalfNo;i++)
{
C_ClcW[i]=Math.round(Math.cos(Math.abs(C_Coef[C_CoefOf+i]+C_Angle))*Car_Image_Width);
C_TotalW+=C_ClcW[i];
}
C_LeftOffset=(C_MaxW-C_TotalW)/2;
for(i=0;i<C_HalfNo;i++)
{
CW_I[i].style.left=C_LeftOffset+"px";
CW_I[i].style.width=C_ClcW[i]+"px";
C_LeftOffset+=C_ClcW[i];
}
C_Angle+=Car_Speed/720*Math.PI*(Car_Direction?-1:1);
if((Car_Direction&&C_Angle<=0)||(!Car_Direction&&C_Angle>=Math.PI/C_HalfNo))
{
if(C_CrImg==Car_Image_Sources.length)C_CrImg=0;
if(Car_Direction)
{
CW_I[C_HalfNo]=CW_I[0];
for(i=0;i<C_HalfNo;i++)CW_I[i]=CW_I[i+1];
CW_I[C_HalfNo-1].src=Car_Image_Sources[C_CrImg];
CW_I[C_HalfNo-1].lnk=Car_Image_Sources[C_CrImg+1]
}
else
{ for(i=C_HalfNo;i>0;i--)CW_I[i]=CW_I[i-1];
CW_I[0]=CW_I[C_HalfNo];
CW_I[0].src=Car_Image_Sources[C_CrImg];
CW_I[0].lnk=Car_Image_Sources[C_CrImg+1]}
C_Angle=Car_Direction?Math.PI/C_HalfNo:0;C_CrImg+=2
}
}
setTimeout("CarImages()",50)} function C_LdLnk()
{
if(this.lnk)window.location.href=this.lnk;
}
function C_Stp()
{
this.style.cursor=this.lnk?"pointer":"default";
C_Stppd=true;
}
function C_Rstrt()
{
C_Stppd=false;
}
</script>
<div id="Carousel" style="position:relative">
<img src="photo/200310171/placeholder.gif" width="371" height="225">
</div>
<body onload="Carousel()">更换其中的图片
Car_Image_Sources=new Array(
"shubin.JPG","shubin.JPG",
"sss.bmp","sss.bmp",
"ss.JPG","ss.JPG",
"da.JPG","da.JPG",
"binbin.JPG","binbin.JPG",
"shubin1.JPG","shubin1.JPG",
"shubin2.JPG","shubin2.JPG",
"1.JPG","1.JPG",
"2.JPG","2.JPG",
"3.JPG","3.JPG",
"4.JPG","4.JPG",
"5.JPG","5.JPG",
"6.JPG","6.JPG"
);
注意 每张图片需要注入2次 这是网上的一个代码 以前看过 嘿嘿