图片幻灯片效果代码 带数字按钮切换

经过新客网编辑测试,可以正常使用,非常不错的代码。

代码如下(代码保存到网页中即可演示):

<TABLE width="100%" height="135" border=0 cellPadding=0 cellSpacing=0>
<TBODY>
<TR>
<TD>
<STYLE type=text/css>
#imgTitle {
FILTER: ALPHA(opacity=70); LEFT: -5px; OVERFLOW: hidden; POSITION: relative; TEXT-ALIGN: left
}
#imgTitle_up {
LEFT: 0px; HEIGHT: 1px; TEXT-ALIGN: left
}
#imgTitle_down {
LEFT: 0px; TEXT-ALIGN: right
}
.imgClass {
BORDER-RIGHT: #fff 1px solid; BORDER-TOP: #fff 1px solid; BORDER-LEFT: #fff 1px solid; BORDER-BOTTOM: #fff 1px solid
}
#txtFrom {
VERTICAL-ALIGN: middle; PADDING-TOP: 2px; TEXT-ALIGN: center
}
.button {
PADDING-RIGHT: 7px; PADDING-LEFT: 7px; BACKGROUND: #7b7b63; PADDING-BOTTOM: 2px; MARGIN: 0px; FONT: bold 9px sans-serif; BORDER-LEFT: #fff 1px solid; PADDING-TOP: 2px; TEXT-DECORATION: none
}
A.button {
COLOR: #ffffff; FONT-FAMILY: sans-serif; BACKGROUND-COLOR: #000000; TEXT-DECORATION: none
}
A.button:link {
COLOR: #ffffff; FONT-FAMILY: sans-serif; BACKGROUND-COLOR: #000000; TEXT-DECORATION: none
}
A.button:visited {
COLOR: #ffffff; FONT-FAMILY: sans-serif; BACKGROUND-COLOR: #000000; TEXT-DECORATION: none
}
A.button:hover {
BACKGROUND: #fff; COLOR: #fff; FONT-FAMILY: sans-serif; TEXT-DECORATION: none
}
.buttonDiv {
BACKGROUND: #000000; FLOAT: left; VERTICAL-ALIGN: middle; WIDTH: 21px; HEIGHT: 1px; TEXT-ALIGN: center
}
.trans {
FILTER: progid:DXImageTransform.Microsoft.Alpha(startX=0, startY=0, finishX=100, finishY=100,style=1,opacity=0,finishOpacity=40); WIDTH: 90px; BACKGROUND-COLOR: #000
}
</STYLE><SCRIPT language=javascript type=text/javascript>
var imgWidth=569;
var imgHeight=154;
var textFromHeight=0;
var textStyle="f12";
var textLinkStyle="p1";
var buttonLineOn="#f60";
var buttonLineOff="#000";
var TimeOut=5000;
var imgUrl=new Array();
var imgLink=new Array();
var imgtext=new Array();
var imgAlt=new Array();
var adNum=0;

document.write(‘<style type="text/css">’);
document.write(‘#focuseFrom{width:’+(imgWidth+0)+’;margin: 0px; padding:0px;height:’+(imgHeight+textFromHeight)+’px; overflow:hidden;}’);
document.write(‘#txtFrom{height:’+textFromHeight+’px;line-height:’+textFromHeight+’px;width:’+imgWidth+’px;overflow:hidden;}’);
document.write(‘#imgTitle{width:’+imgWidth+’;top:-‘+(textFromHeight+28)+’px;height:18px}’);
document.write(‘</style>’);
document.write(‘<div id="focuseFrom" style="WIDTH:’+imgWidth+’px;HEIGHT:’+imgHeight+’px;">’);

imgUrl[1] = new Image;
imgUrl[1].src=’http://www.maxin.cn/uploads/allimg/100625/202HUP1-0.jpg’;
imgtext[1]='<A HREF="http://www.xker.com/" TARGET="_blank" title="基金定投" class="’+textLinkStyle+’">基金定投</A>’;
imgLink[1]=’http://www.xker.com/’;
imgAlt[1]=’基金定投’;
imgUrl[2] = new Image;
imgUrl[2].src=’http://www.maxin.cn/uploads/allimg/100625/202HTJ2-1.jpg’;
imgtext[2]='<A HREF="http://www.xker.com/" TARGET="_blank" title="网银理财巧当家" class="’+textLinkStyle+’">网银理财巧当家</A>’;
imgLink[2]=’http://www.xker.com/’;
imgAlt[2]=’网银理财巧当家’;
imgUrl[3] = new Image;
imgUrl[3].src=’http://www.maxin.cn/uploads/allimg/100625/202HRB7-2.jpg’;
imgtext[3]='<A HREF="http://www.xker.com/" TARGET="_blank" title="芭比信用卡" class="’+textLinkStyle+’">芭比信用卡</A>’;
imgLink[3]=’http://www.xker.com/’;
imgAlt[3]=’芭比信用卡’;

function changeimg(n)
{
adNum=n;
window.clearInterval(theTimer);
adNum=adNum-1;
nextAd();
}
function goUrl(){
window.open(imgLink[adNum],’_blank’);
}

if (navigator.appName == "Netscape")
{
document.write(‘<style type="text/css">’);
document.write(‘.buttonDiv{height:4px;width:21px;}’);
document.write(‘</style>’);
function nextAd(){
if(adNum<(imgUrl.length-1))adNum++;
else adNum=1;
theTimer=setTimeout("nextAd()", TimeOut);
document.images.imgInit.src=imgUrl[adNum].src;
document.images.imgInit.alt=imgAlt[adNum];
document.getElementById(‘focustext’).innerHTML=imgtext[adNum];
document.getElementById(‘ilink’+adNum).style.background=buttonLineOn;
document.getElementById(‘imgLink’).href=imgLink[adNum];
for (var i=1;i<=imgUrl.length;i++)
{
if (i!=adNum){document.getElementById(‘ilink’+i).style.background=buttonLineOff;}
}
}
document.write(‘<a id="imgLink" href="’+imgLink[1]+’" target=_blank class="linkwhite"><img src="’+imgUrl[1].src+’" name="imgInit" width=’+imgWidth+’ height=’+imgHeight+’ border=0 alt="’+imgAlt[1]+’" class="imgClass" style=" margin-left:1px"></a><div id="txtFrom"><span id="focustext" class="’+textStyle+’">’+imgtext[1]+'</span></div>’)
document.write(‘<div id="imgTitle">’);
document.write(‘<div id="imgTitle_down">’);

for(var i=1;i<imgUrl.length;i++){document.write(‘<a id="ilink’+i+’" href="javascript:changeimg(‘+i+’)" class="button" style="cursor:hand" title="’+imgAlt[i]+’">’+i+'</a>’);}
document.write(‘</div>’);
document.write(‘</div>’);
document.write(‘</div>’);
nextAd();
}
else
{
var count=0;
for (i=1;i<imgUrl.length;i++) {
if( (imgUrl[i]!="") && (imgLink[i]!="")&&(imgtext[i]!="")&&(imgAlt[i]!="") ) {
count++;
} else {
break;
}
}
function playTran(){
if (document.all)
imgInit.filters.revealTrans.play();
}
var key=0;
function nextAd(){
if(adNum<count)adNum++ ;
else adNum=1;

if( key==0 ){
key=1;
} else if (document.all){
imgInit.filters.revealTrans.Transition=23;
imgInit.filters.revealTrans.apply();
playTran();
}
document.images.imgInit.src=imgUrl[adNum].src;
document.images.imgInit.alt=imgAlt[adNum];
document.getElementById(‘ilink’+adNum).style.background=buttonLineOn;
for (var i=1;i<=count;i++)
{
if (i!=adNum){document.getElementById(‘ilink’+i).style.background=buttonLineOff;}
}
focustext.innerHTML=imgtext[adNum];
theTimer=setTimeout("nextAd()", TimeOut);
}
document.write(‘<a target=_self href="javascript:goUrl()"><img style="FILTER: revealTrans(duration=1,transition=5);" src="javascript:nextAd()" width=’+imgWidth+’ height=’+imgHeight+’ border=0 vspace="0" name=imgInit class="imgClass"></a>’);
document.write(‘<div id="txtFrom"><span id="focustext" class="’+textStyle+’"></span></div>’);
document.write(‘<div id="imgTitle">’);
document.write(‘ <div id="imgTitle_down"> <a class="trans"></a>’);
for(var i=1;i<imgUrl.length;i++){document.write(‘<a id="ilink’+i+’" href="javascript:changeimg(‘+i+’)" class="button" style="cursor:hand" title="’+imgAlt[i]+’" onFocus="this.blur()">’+i+'</a>’);}
document.write(‘</div>’);
document.write(‘</div>’);
document.write(‘</div>’);
nextAd();
}
</SCRIPT>
</TD>
</TR></TBODY></TABLE>

转自:http://www.xker.com/page/e2010/0625/97018.html

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注