87,992
社区成员
发帖
与我相关
我的任务
分享

<script type="text/javascript">
function changeaweb(srcObj, tid) {
var tabList = srcObj.parentNode.getElementsByTagName("li");
if (srcObj.className == 'a1') return;
for (var i = 0; i < tabList.length; i++) {
if (tabList[i].className == 'a1')
tabList[i].className = 'b1';
tabList[i].className = 'c1';
tabList[i].className = 'd1';
document.getElementById("web" + (i + 1)).style.display = 'none';
}
document.getElementById("web" + tid).style.display = '';
srcObj.className = 'a1';
return false;
}
var tabs = {
liList: null,
autoTime: 1000,
mouseTime: 500,
timeObj: null,
index: 0,
doInit: function() {
this.liList = document.getElementById("ul").getElementsByTagName("li");
this.bindEvent();
this.auto();
},
bindEvent: function() {
for (var i = 0; i < this.liList.length; i++) {
(function(i, tab) {
tab.liList[i].onmouseover = function() {
var obj = this;
clearTimeout(tab.timeObj);
tab.timeObj = setTimeout(function() {
changeaweb(obj, i + 1);
tab.index = i;
}, tab.mouseTime);
};
tab.liList[i].onmouseout = function() {
clearTimeout(tab.timeObj);
tab.auto();
};
})(i, this);
}
},
auto: function(srcObj, tid) {
(function(tab) {
tab.timeObj = setInterval(function() {
tab.index++;
tab.index = tab.index < tab.liList.length ? tab.index : 0;
changeaweb(tab.liList[tab.index], tab.index + 1);
}, tab.autoTime);
})(this);
}
};
tabs.doInit();
</script>
<script type="text/javascript">
function changeaweb(srcObj, tid) {
var tabList = srcObj.parentNode.getElementsByTagName("li");
if (srcObj.className == 'a1') return;
for (var i = 0; i < tabList.length; i++) {
if (tabList[i].className == 'a1')
tabList[i].className = 'b1';
tabList[i].className = 'c1';
tabList[i].className = 'd1';
document.getElementById("web" + (i + 1)).style.display = 'none';
}
document.getElementById("web" + tid).style.display = '';
srcObj.className = 'a1';
return false;
}
var obj = document.getElementById("ul").getElementsByTagName("li");
var timeout;
for (var i = 0; i < obj.length; i++) {
(function(i) {
obj[i].onmouseover = function() {
var obj = this;
clearTimeout(timeout);
timeout = setTimeout(function() {
changeaweb(obj, i + 1);
}, 500);
};
obj[i].onmouseout = function() {
clearTimeout(timeout);
};
})(i);
}
</script>