大家好,又见面了,我是你们的朋友全栈君。
javascript超强幻灯片代码
[code]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<style type=”text/css”>
<!–
#f_div{
width:150px;
height:100px;
overflow:hidden;
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: 0px;
}
#f_imgDiv{width:100%; height:100px; overflow:hidden;}
#f_img{filter:progid:DXImageTransform.Microsoft.Fade(Overlap=1.00); border:0;}
#f_infoDiv{width:100%;top:-20px !important;top:-22px; position:relative;}
#f_buttonDiv{width:100%; margin-right:1px; height:21px; overflow:hidden; text-align:left;}
#f_line{width:100%;height:1px;background:#fff; overflow:hidden;filter:progid:DXImageTransform.Microsoft.Alpha(startX=0, startY=0, finishX=50, finishY=100,style=1,opacity=0,finishOpacity=100)}
#f_buttonDiv div{width:1px;height:21px; background:#fff; float:right;}
#f_buttonDiv .bg{width:21px; height:21px; background:#fff; float:right; filter:Alpha(Opacity=40);}
#f_buttonDiv a{width:21px;height:15px !important;height:17px;float:right;padding-top:5px;color:#fff;font-family:Arial, Helvetica, sans-serif;font-size:10px;text-align:center;display:block;overflow:hidden;text-decoration:none;position:absolute;}
#f_buttonDiv a:link,#f_buttonDiv a:visited,#f_buttonDiv a:active{color:#000;}
#f_buttonDiv a:hover{background:#FF840C;color:#fff;}
#f_buttonDiv a.on:link,#f_buttonDiv a.on:visited,#f_buttonDiv a.on:active,#f_buttonDiv a.on:hover{background:#FF840C;color:#fff;}
#f_buttonDiv a.on:hover{background:#FF6600;}
#f_text{height:20px; line-height:20px; overflow:hidden;text-align:center;}
#f_text a:link,#f_text a:visited,#f_text a:active{color:#000;text-decoration: none;}
#f_text a:hover{color:#FF6600;text-decoration: none;}
–>
</style>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />
<title>无标题文档</title>
</head>
<body>
<div id=”ad_pic”>
<div id=”f_div”>
<!–图片区域–>
<div id=”f_imgDiv”></div>
<div id=”f_infoDiv”>
<!–数字按钮区域–>
<div id=”f_buttonDiv”></div>
</div>
</div>
<table width=”150″ border=”0″ cellpadding=”0″ cellspacing=”1″ bgcolor=”#FFFFFF”>
<tr>
<td align=”center” bgcolor=”#EFEFEF”>
<!–焦点文字区域–>
<div id=”f_text” class=”f12b”></div>
<script language=”javascript” type=”text/javascript”>
<!–
//more javascript from [url]http://www.smallrain.net[/url]
function p$(string){
document.write(string);
}
function $(id){
return document.getElementById(id);
}
function change_menu(id,content_id,num,total_ztc_menu,menu_on,menu_off){
for (var i=1;i<=total_ztc_menu;i++){
$(id+i).className=menu_off;
$(content_id+i).style.display=’none’;
}
$(id+num).className=menu_on;
$(content_id+num).style.display=’block’;
}
//可修改区域
var imgWidth=150;
var imgHeight=100;
var _timeOut_=5000;
var show_text = true; //是否显示焦点文字
var timeOut=_timeOut_;
var timeOut2=_timeOut_/2;//onmouseout img后需要切换的时间
var now=0; //第一张图
var target=”_blank”; //打开方式
var button_on =’on’; //当前焦点对应按钮的样式名
var button_off =”;//非当前焦点对应按钮的样式名
//不可修改区域
var imgUrl = new Array();
var imgText = new Array();
var imgLink = new Array();
var imgAlt= new Array();
var menuList = new Array();//菜单menu
var ver=2; //兼容浏览器版本 默认2 为非ie
var firstTime=true;
var n =-1;
//菜单menu
menuList[++n]=’XX’;
imgUrl[n]=’http://show.skyhits.com/images/pic_1.jpg’;
imgText[n]='<a href=”#” target=”_blank”>内容一</a>’;
imgLink[n]=’http://show.skyhits.com/moive/14/show1.htm’;
imgAlt[n]=’内容一’;
//菜单menu
menuList[++n]=’XX’;
imgUrl[n]=’http://show.skyhits.com/images/pic_2.jpg’;
imgText[n]='<a href=”#” target=”_blank”>内容二</a>’;
imgLink[n]=’http://show.skyhits.com/society/70/show1.htm’;
imgAlt[n]=’内容二’;
//菜单menu
menuList[++n]=’XX’;
imgUrl[n]=’http://show.skyhits.com/images/pic_3.jpg’;
imgText[n]='<a href=”#” target=”_blank”>内容三</a>’;
imgLink[n]=’http://show.skyhits.com/movie/17/show1.htm’;
imgAlt[n]=’内容三’;
//菜单menu
menuList[++n]=’XX’;
imgUrl[n]=’http://show.skyhits.com/images/pic_4.jpg’;
imgText[n]='<a href=”#” target=”_blank”>内容四</a>’;
imgLink[n]=’http://show.skyhits.com/society/52/show1.htm’;
imgAlt[n]=’内容四’;
//菜单menu
menuList[++n]=’XX’;
imgUrl[n]=’http://show.skyhits.com/images/pic_5.jpg’;
imgText[n]='<a href=”#” target=”_blank”>内容四</a>’;
imgLink[n]=’http://show.skyhits.com/society/61/show1.htm’;
imgAlt[n]=’内容四’;
var count=0;
for (var i=0;i<imgUrl.length;i++) {
if( (imgUrl[i]!=””) && (imgText[i]!=””)&& (imgLink[i]!=””)&& (imgAlt[i]!=””)) {
count++;
} else {
break;
}
}
//重写css
var each_width=Math.ceil((imgWidth-(count-1))/count);
var last_width=imgWidth-each_width*(count-1)-(count)+1;
function change(){
if (ver==1){
with($(‘f_img’).filters[0]){
Transition=1;
apply();
play();
}
}
if (firstTime){ firstTime=false;timeOut=_timeOut_/1000;}
else{
$(‘f_img’).src=imgUrl[now];
$(‘f_img’).alt=imgAlt[now];
$(‘f_imgLink’).href=imgLink[now];
if (show_text) $(‘f_text’).innerHTML=imgText[now];
for (var i=0;i<count;i++) {
$(‘b’+i).className=”button”;
//$(‘f_menu’+i).className=””;
}
$(‘b’+now).className=”on”;
//$(‘f_menu’+now).className=”on”;
now=(now>=imgUrl.length-1)?0:now+1;
timeOut=_timeOut_;
}
theTimer=setTimeout(“change()”, timeOut);
}
function b_change(num){
window.clearInterval(theTimer);
now=num;
firstTime=false;
change();
}
//draw 渐变line (即css:f_line)
function draw_line(){
var div = document.createElement(“div”);
div.id = ‘f_line’;
$(‘f_infoDiv’).insertBefore(div,$(‘f_infoDiv’).childNodes.item(0));
}
//表现层 start
//图片
var a = document.createElement(“a”);
a.id=”f_imgLink”;
a.target=target;
a.href=imgLink[now];
$(‘f_imgDiv’).appendChild(a);
var img = document.createElement(“img”);
img.id=”f_img”;
img.width=imgWidth;
img.height=imgHeight;
img.src=imgUrl[now];
img.alt=imgAlt[now];
a.appendChild(img);
//数字按钮
for (var i=count-1;i>=0;i–){
var div_bg = document.createElement(“div”);
div_bg.id = ‘div_bg’+i;
div_bg.className=’bg’;
$(‘f_buttonDiv’).appendChild(div_bg);
var a = document.createElement(“a”);
a.id = ‘b’+i;
a.className = (i==now+1)?”button_on”:”button_off”;
a.title=imgAlt[i];
a.innerHTML=i+1;
a.href=’javascript:b_change(‘+i+’)’;
$(‘div_bg’+i).appendChild(a);
var div= document.createElement(“div”);
$(‘f_buttonDiv’).appendChild(div);
}
if (show_text) $(‘f_text’).innerHTML = imgText[now];
//表现层 end
$(‘f_img’).οnmοuseοver=function(){window.clearInterval(theTimer);}
$(‘f_img’).οnmοuseοut=function(){theTimer=setTimeout(“change()”, timeOut2);}
try{ //滤镜版本
new ActiveXObject(“DXImageTransform.Microsoft.Fade”);
$(‘f_img’).filters[0].play();
ver=1;
draw_line();
}
catch (e){ver=2;}
var theTimer = setTimeout(“change()”, _timeOut_/1000);
//–>
</script>
</td>
</tr>
</table>
</div>
</body>
</html>[/code]
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/158569.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...