You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//获取idtagName
function getIdName(id,tagName){
if(tagName!=0){
return document.getElementById(id).getElementsByTagName(tagName);
}else{
return document.getElementById(id);
}
}
function hdp(json){
var tiemr=null;
var pd=0;
var index=0;
var that;
var option={
li:"li", //默认值默认用li包裹
boxid:"", //最外面div id
imgid:"", //图片外面id
optid:"", //opt外面id
an:"", //左右按钮id用于移上显示和隐藏
prev:"", //左边箭头id
next:"", //右边箭头id
ms:800 //多少毫秒切换一张,默认800毫秒
}
for(var i in option){
if(json[i]!=undefined){
option[i]=json[i];
}
}
var div=getIdName(option.boxid,0);
var imgs=getIdName(option.imgid,option.li);
var lis=getIdName(option.optid,option.li);
var an=getIdName(option.an,0);
var prev=getIdName(option.prev,0);
var next=getIdName(option.next,0);
var ms=option.ms;
function lbt(that){
if(that>=0){
index=that;
}else{
if(pd==0){
index++;
}else{
index--;
pd=0;
}
}
if(index>=lis.length) index=0;
if(index<0) index=lis.length-1;
for(var j=0;j<lis.length;j++){
lis[j].className="";
imgs[j].className="";
}
lis[index].className="on";
imgs[index].className="current";
}
imgs[index].className="current";
lis[index].className="on";
for(var i=0;i<lis.length;i++){
lis[i].index=i;
lis[i].onclick=function(){
that=this.index;
lbt(that);
}
}
timer=setInterval(lbt,ms);
div.onmouseover=function(){
clearInterval(timer);
an.style.display="block";
}
div.onmouseout=function(){
timer=setInterval(lbt,ms);
an.style.display="none";
}
prev.onclick=function(){
pd=1;
lbt();
}
next.onclick=function(){
pd=0;
lbt();
}
}