账号通
    

账号  

密码  

1958

查看

1

回复
主题:发一个类似新浪首面幻灯片的图片轮播效果吧 [收藏主题]  
hyz1154 当前离线

250

主题

0

广播

0

粉丝
添加关注
级别:二年级

用户积分:655 分
登录次数:132 次
注册时间:2006/12/14
最后登录:2019/3/10
hyz1154 发表于:2010/6/3 21:25:00   | 只看该作者 查看该作者主题 楼主 
做在线知识付费 选科汛云开店

发一个类似新浪首面幻灯片的图片轮播效果吧,有需要的朋友就拿去吧,当然要配合科讯后台用的话,我需要改一下,自己动手吧。


 


<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>首页大焦点图-dtsanguo</title>
<style type="text/css">
<!--


@charset "gb2312";
table,td,select,input,div {font-size:12px;}
body { font-size:12px; padding:0; margin:0; height:auto;}
a img {border:0;}
form,input,select,ul,li{margin:0;padding:0;}


-->
</style></head>
<body>
<style type="text/css">
/* 数字按钮框样式 */
#imgTitle {FILTER:ALPHA(opacity=70);position:relative;left:0px;text-align:left;overflow: hidden;}
#imgTitle_up {left:0px;text-align: left; height:1px; width:inherit; }
#imgTitle_down {left:0px;text-align: right; width:inherit; }
/* 图片框样式 */
.imgClass {border: 0px solid #000;}
/* 图片文字框样式 */
#txtFrom {text-align: center;vertical-align: middle;}
/* 数字按钮样式 */
.button {text-decoration: none;padding: 2px 7px;background: #7B7B63;margin: 0px;font: bold 9px sans-serif; border-left:#fff 1px solid;}
a.button, a.button:link, a.button:visited {font-family: sans-serif;text-decoration: none;color:#FFFFFF;background-color: #000000;}
a.button:hover {font-family: sans-serif;text-decoration: none;color:#fff;background:#fff; }
.buttonDiv {background: #000000;height: 1px;width: 21px;float: left;text-align: center;    vertical-align: middle;}
/*渐变*/
.trans {width:90px; background-color:#000;filter : progid:DXImageTransform.Microsoft.Alpha(startX=0, startY=0, finishX=100, finishY=100,style=1,opacity=0,finishOpacity=40);}
</style>
<script language="javascript" type="text/javascript">
var imgWidth=284;              //图片宽
var imgHeight=369;             //图片高
var textFromHeight=0;         //焦点字框高度 (单位为px)
var textStyle="f12";           //焦点字class style (不是连接class)
var textLinkStyle="p1"; //焦点字连接class style
var buttonLineOn="#f00";           //button下划线on的颜色
var buttonLineOff="#000";          //button下划线off的颜色
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+2)+';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+16)+'px;height:18px}');
document.write('</style>');
document.write('<div id="focuseFrom">');
//焦点字框高度样式表 结束



imgUrl[1]='http://img2.pconline.com.cn/pconline/desktops/guide/1006/350_200_1.jpg';
imgtext[1]='<A HREF="#" TARGET="_blank" class="'+textLinkStyle+'">武将1</A>';
imgLink[1]='#';
imgAlt[1]='武将1';


 



imgUrl[2]='http://img2.pconline.com.cn/pconline/digital/dc/daogou/market/1006/100603_x350.jpg';
imgtext[2]='<A HREF="#" TARGET="_blank" class="'+textLinkStyle+'">武将2</A>';
imgLink[2]='#';
imgAlt[2]='武将2';



imgUrl[3]='http://imgad1.3conline.com/ivy/image/20106/3/1275529621806.jpg';
imgtext[3]='<A HREF="#" TARGET="_blank" class="'+textLinkStyle+'">武将3</A>';
imgLink[3]='#';
imgAlt[3]='武将3';


 


function changeimg(n)
{
    adNum=n;
    window.clearInterval(theTimer);
    adNum=adNum-1;
    nextAd();
}
function goUrl(){
window.open(imgLink[adNum],'_blank');
}
//NetScape开始
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];
    document.images.imgInit.alt=imgAlt[adNum];   
    document.getElementById('focustext').innerHTML=imgtext[adNum];
    document.getElementById('imgLink').href=imgLink[adNum];


}
    document.write('<a id="imgLink" href="'+imgLink[1]+'" target=_blank class="p1"><img src="'+imgUrl[1]+'" name="imgInit" width='+imgWidth+' height='+imgHeight+' border=1 alt="'+imgAlt[1]+'" class="imgClass"></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 href="javascript:changeimg('+i+')" class="button" style="cursor:hand" title="'+imgAlt[i]+'">'+i+'</a>');}
//数字按钮代码结束
    document.write('</div>');
    document.write('</div>');
    document.write('</div>');
    nextAd();
}
//NetScape结束
//IE开始
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];
    document.images.imgInit.alt=imgAlt[adNum];   
    document.getElementById('link'+adNum).style.background=buttonLineOn;
    for (var i=1;i<=count;i++)
    {
       if (i!=adNum){document.getElementById('link'+i).style.background=buttonLineOff;}
    }   
    focustext.innerHTML=imgtext[adNum];
    theTimer=setTimeout("nextAd()", TimeOut);
}
window.onload=nextAd;
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="link'+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>');
}
//IE结束
</script>
</body>
</html>

 
  支持(0) | 反对(0) 回到顶部顶端 回到底部底部
cfsz11 当前离线

1

主题

0

广播

0

粉丝
添加关注
级别:学前班

用户积分:4 分
登录次数:2 次
注册时间:2015/4/6
最后登录:2015/4/8
cfsz11 发表于:2015/4/6 22:20:37   | 只看该作者 查看该作者主题 沙发 
科汛智能建站系统
加油很感谢这个帖子, 代码很实用。 谢谢楼主。
 
  支持(0) | 反对(0) 回到顶部顶端 回到底部底部
<上一主题 | 下一主题 >
Powered By KesionCMS Version X1
厦门科汛软件有限公司 © 2006-2016 页面执行0.07813秒 powered by KesionCMS 9.0