标签:
<script>
// 函数不能重名, --> 子函数
// is defined function --> 函数名是否写错了
function AutoTab(id) {
Tab.apply(this, arguments);
this.timer = null;
this.inits();
// this.autoPlay();
}
AutoTab.prototype = new Tab();
AutoTab.prototype.constructor = AutoTab;
// 初始化
AutoTab.prototype.inits = function () {
this.play();
this.over();
this.out();
};
// 自动播放
AutoTab.prototype.play = function(){
var _this = this;
this.timer = setInterval(function(){
_this.iNow++;
if(_this.iNow==_this.aBtn.length){
_this.iNow = 0;
}
_this.tab();
},1000);
};
// 停止
AutoTab.prototype.stop = function () {
clearInterval(this.timer);
};
// 鼠标经过
AutoTab.prototype.over = function () {
var _this = this;
this.oBox.onmouseover = function () {
_this.stop();
};
};
// 鼠标离开
AutoTab.prototype.out = function () {
var _this = this;
this.oBox.onmouseout = function () {
_this.play();
};
};
window.onload=function(){
new Tab(‘tab1‘);
new AutoTab(‘tab2‘);
};
</script>
标签:
原文地址:http://www.cnblogs.com/zsongs/p/5595480.html