只有几句的js图片切换特效赏析
2011-04-28 18:02
639 查看
//...
var imageTaber = {
id: "HotNewsImage",
sum: 4,
currentTabId: 0,
oldTabId: 0,
imgs: ["Themes/56Fix_20110312/Images/B_1.jpg", "Themes/56Fix_20110312/Images/B_2.jpg", "Themes/56Fix_20110312/Images/B_3.jpg", "Themes/56Fix_20110312/Images/ygfcpic_11.gif"],
tab: function(n, auto) {
imageTaber.isAuto = auto;
if (auto) {
this.oldTabId = this.currentTabId == 0 ? this.sum: this.currentTabId - 1;
} else {
this.oldTabId = this.currentTabId;
this.currentTabId = n;
}
document.getElementById("imageTaber_" + this.oldTabId).className = "";
document.getElementById("imageTaber_" + n).className = "current";
document.getElementById(this.id).src = this.imgs
;
//HotNewsImageContainer.filters[0].Apply();
//HotNewsImageContainer.filters[0].Play();
},
isAuto: false,
timer: null,
autoTab: function() {
if (imageTaber.isAuto) {
if (imageTaber.currentTabId < imageTaber.sum) {
imageTaber.currentTabId++;
} else {
imageTaber.currentTabId = 0;
}
imageTaber.tab(imageTaber.currentTabId, true);
}
if (imageTaber.timer == null) {
imageTaber.timer = setInterval("imageTaber.autoTab()", 3000);
imageTaber.isAuto = true;
}
},
reAuto: function() {
imageTaber.isAuto = true;
}
}
可以实现自动切换与手动切换。
实例:http://www.56fix.com/
作者网站:万家乐热水器维修
var imageTaber = {
id: "HotNewsImage",
sum: 4,
currentTabId: 0,
oldTabId: 0,
imgs: ["Themes/56Fix_20110312/Images/B_1.jpg", "Themes/56Fix_20110312/Images/B_2.jpg", "Themes/56Fix_20110312/Images/B_3.jpg", "Themes/56Fix_20110312/Images/ygfcpic_11.gif"],
tab: function(n, auto) {
imageTaber.isAuto = auto;
if (auto) {
this.oldTabId = this.currentTabId == 0 ? this.sum: this.currentTabId - 1;
} else {
this.oldTabId = this.currentTabId;
this.currentTabId = n;
}
document.getElementById("imageTaber_" + this.oldTabId).className = "";
document.getElementById("imageTaber_" + n).className = "current";
document.getElementById(this.id).src = this.imgs
;
//HotNewsImageContainer.filters[0].Apply();
//HotNewsImageContainer.filters[0].Play();
},
isAuto: false,
timer: null,
autoTab: function() {
if (imageTaber.isAuto) {
if (imageTaber.currentTabId < imageTaber.sum) {
imageTaber.currentTabId++;
} else {
imageTaber.currentTabId = 0;
}
imageTaber.tab(imageTaber.currentTabId, true);
}
if (imageTaber.timer == null) {
imageTaber.timer = setInterval("imageTaber.autoTab()", 3000);
imageTaber.isAuto = true;
}
},
reAuto: function() {
imageTaber.isAuto = true;
}
}
可以实现自动切换与手动切换。
实例:http://www.56fix.com/
作者网站:万家乐热水器维修
相关文章推荐
- 【js特效】这个方式的图片切换效果,谁有现成的啊?
- 各大门户网站Flash和JS实现的图片幻灯片切换特效代码文件下载
- Flash和JS实现的图片幻灯片切换特效
- JS图片自动和可控的轮播切换特效
- JS组件系列——图片切换特效:简易抽奖系统
- 利用JS进行图片的切换即特效展示图片
- 常用首页JS图片切换特效
- 图片切换特效(js)
- JS组件系列——图片切换特效:简易抽奖系统
- (js特效) js代码实现图片切换
- js图片轮播手动切换特效
- 滚动图片切换连播(JavaScript特效 | JS特效源代码)
- 用html+css+js实现的一个简单的图片切换特效
- js鼠标点击按钮切换图片-图片自动切换-点击左右按钮切换特效代码
- js图片模糊切换显示特效的方法
- 图文列表和图片列表JS切换特效代码
- 非常漂亮的JS+CSS图片幻灯切换特效
- 各大门户网站Flash和JS实现的图片幻灯片切换特效代码文件下载:
- Flash和JS实现的图片幻灯片切换特效
- JS图片自动和可控的轮播切换特效