1.index.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>一个JS大图轮播器</title> <link href="css/css.css" mce_href="css/css.css" rel="stylesheet" type="text/css"> <SCRIPT language=javascript src="js/AutoChangePhoto.js" mce_src="js/AutoChangePhoto.js"></SCRIPT> <mce:style type="text/css"><!-- body { background-color: #FFFFFF; } --></mce:style><style type="text/css" mce_bogus="1">body { background-color: #FFFFFF; }</style></head> <!--注意以下链接http://blog.csdn.net/elifefly是示例,请根据实际需要修改,或者添加相应代码修改成动态。elifefly--> <body> <DIV class=fpic> <A id=foclnk href="http://blog.csdn.net/elifefly" mce_href="http://blog.csdn.net/elifefly" target=_blank><IMG id=focpic style="FILTER: RevealTrans ( duration = 1,transition=23 ); VISIBILITY: visible; POSITION: absolute" mce_style="FILTER: RevealTrans ( duration = 1,transition=23 ); VISIBILITY: visible; POSITION: absolute" height=300 alt="" src="images/01.jpg" mce_src="images/01.jpg" width=400></A> <DIV id=fttltxt style="MARGIN-TOP: 305px; FLOAT: left; WIDTH: 400px; TEXT-ALIGN: center"><A href="http://blog.csdn.net/elifefly" target=_blank>梦:品味音乐人生</A></DIV> <DIV style="MARGIN-LEFT: 402px; WIDTH: 65px"> <DIV class=thubpiccur id=tmb0 onmouseover=setfoc(0); onmouseout=playit();><A href="http://blog.csdn.net/elifefly" target=_blank><IMG src="images/01.jpg" alt="" width=56 height=42 border="0"></A></DIV> <DIV class=thubpic id=tmb1 onmouseover=setfoc(1); onmouseout=playit();><A href="http://blog.csdn.net/elifefly" target=_blank><IMG height=45 alt="" src="images/02.jpg" width=56></A></DIV> <DIV class=thubpic id=tmb2 onmouseover=setfoc(2); onmouseout=playit();><A href="http://blog.csdn.net/elifefly" target=_blank><IMG height=45 alt="" src="images/03.jpg" width=56></A></DIV> <DIV class=thubpic id=tmb3 onmouseover=setfoc(3); onmouseout=playit();><A href="http://blog.csdn.net/elifefly" target=_blank><IMG height=45 alt="" src="images/04.jpg" width=56></A></DIV> <DIV class=thubpic id=tmb4 onmouseover=setfoc(4); onmouseout=playit();><A href="http://blog.csdn.net/elifefly" target=_blank><IMG height=45 alt="" src="images/05.jpg" width=56></A></DIV> <DIV class=thubpic id=tmb5 onmouseover=setfoc(5); onmouseout=playit();><A href="http://blog.csdn.net/elifefly" target=_blank><IMG height=45 alt="" src="images/06.jpg" width=56></A></DIV> <SCRIPT language=javascript type=text/javascript> var picarry = {}; var lnkarry = {}; var ttlarry = {}; picarry[0] = "images/01.jpg"; lnkarry[0] = "http://blog.csdn.net/elifefly"; ttlarry[0] = "品味音乐人生"; picarry[1] = "images/02.jpg"; lnkarry[1] = "http://blog.csdn.net/elifefly"; ttlarry[1] = "Linux盛宴"; picarry[2] = "images/03.jpg"; lnkarry[2] = "http://blog.csdn.net/elifefly"; ttlarry[2] = "血性"; picarry[3] = "images/04.jpg"; lnkarry[3] = "http://blog.csdn.net/elifefly"; ttlarry[3] = "唯美"; picarry[4] = "images/05.jpg"; lnkarry[4] = "http://blog.csdn.net/elifefly"; ttlarry[4] = "胸怀"; picarry[5] = "images/06.jpg"; lnkarry[5] = "http://blog.csdn.net/elifefly"; ttlarry[5] = "精神"; </SCRIPT> </DIV></DIV> <br> </body> </html>
2.js文件夹下的AutoChangePhoto.js
var currslid = 0; var slidint; function setfoc(id){ document.getElementById("focpic").src = picarry[id]; document.getElementById("foclnk").href = lnkarry[id]; document.getElementById("fttltxt").innerHTML = ''+ttlarry[id]+''; currslid = id; for(i=0;i<6;i++){ document.getElementById("tmb"+i).className = "thubpic"; }; document.getElementById("tmb"+id).className ="thubpiccur"; focpic.style.visibility = "hidden"; focpic.filters[0].Apply(); if (focpic.style.visibility == "visible") { focpic.style.visibility = "hidden"; focpic.filters.revealTrans.transition=23; } else { focpic.style.visibility = "visible"; focpic.filters[0].transition=23; } focpic.filters[0].Play(); stopit(); } function playnext(){ if(currslid==5){ currslid = 0; } else{ currslid++; }; setfoc(currslid); playit(); } function playit(){ slidint = setTimeout(playnext,4500); } function stopit(){ clearTimeout(slidint); } window.onload = function(){ playit(); }
3.css文件夹下的css.css
BODY { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12px; BACKGROUND: #000; PADDING-BOTTOM: 0px; MARGIN-LEFT: auto; COLOR: #f6f6ee; MARGIN-RIGHT: auto; PADDING-TOP: 0px; FONT-FAMILY: 宋体; HEIGHT: 490px; TEXT-ALIGN: center } A { COLOR: #fff; TEXT-DECORATION: none } A:hover { COLOR: #fff; TEXT-DECORATION: underline } .fpic { BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; Z-INDEX: 3; BACKGROUND: #000; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 476px; POSITION: relative; HEIGHT: 330px; BORDER-RIGHT-WIDTH: 0px;BORDER: #dddddd 1px solid; text-align:center } .bpic { FLOAT: left; MARGIN: 0px; WIDTH: 244px; POSITION: relative; HEIGHT: 243px } #focpic { BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; LEFT: 1px; BORDER-BOTTOM-WIDTH: 0px; POSITION: absolute; TOP: 1px; BORDER-RIGHT-WIDTH: 0px } .thubpic { PADDING-RIGHT: 0px; PADDING-LEFT: 4px; Z-INDEX: 20; PADDING-BOTTOM: 0px; WIDTH: 63px; CURSOR: pointer; PADDING-TOP: 4px; TOP: 10px; HEIGHT: 49px } .thubpiccur { PADDING-RIGHT: 0px; PADDING-LEFT: 4px; Z-INDEX: 20; PADDING-BOTTOM: 0px; WIDTH: 63px; CURSOR: pointer; PADDING-TOP: 4px; TOP: 10px; HEIGHT: 49px } .thubpiccur { Z-INDEX: 30; BACKGROUND: url(../images/arrow3.gif) no-repeat left 50% } .thubpic IMG { BORDER-RIGHT: #666 3px solid; BORDER-TOP: #666 2px solid; BORDER-LEFT: #666 3px solid; WIDTH: 56px; BORDER-BOTTOM: #666 2px solid; HEIGHT: 42px } .thubpiccur IMG { BORDER-RIGHT: #666 3px solid; BORDER-TOP: #666 2px solid; BORDER-LEFT: #666 3px solid; WIDTH: 56px; BORDER-BOTTOM: #666 2px solid; HEIGHT: 42px } .thubpiccur IMG { BORDER-LEFT-COLOR: #fff; BORDER-BOTTOM-COLOR: #fff; BORDER-TOP-COLOR: #fff; BORDER-RIGHT-COLOR: #fff }
4.images文件下对应6张图片,每张图片大小为400X300,格式为jpg。
5.效果图
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛