html轮播左右键,js实现图片点击左右轮播

这篇博客介绍了一个小型的HTML图片轮播框架,通过点击左右按钮或自动播放实现图片滚动。它包括一个js文件play.js,创建了ScrollPic函数来处理轮播逻辑。轮播功能包括手动和自动切换,支持设置切换速度和间隔时间。博主提供了HTML和JavaScript代码示例,并指出只需调整样式和部分参数即可应用于其他项目。
摘要由CSDN通过智能技术生成

这个 相当于一个小框架,拿来就可以用:

1. 功能:

758e5ca5b5543019e6a87990ad03c939.png

如上图显示: 点击左右两个button,可以实现图片向左右滚动,也可以设置在多少秒自己滚动。

2. 首先建立一个js文件,文件名为play.js(只要和HTML中的引入相同就可以了):

var sina = {

$: function(objName) {

if (document.getElementById) {

return eval('document.getElementById("' + objName + '")')

} else {

return eval('document.all.' + objName)

}

},

isIE: navigator.appVersion.indexOf("MSIE") != -1 ? true : false,

addEvent: function(l, i, I) {

if (l.attachEvent) {

l.attachEvent("on" + i, I)

} else {

l.addEventListener(i, I, false)

}

},

delEvent: function(l, i, I) {

if (l.detachEvent) {

l.detachEvent("on" + i, I)

} else {

l.removeEventListener(i, I, false)

}

},

readCookie: function(O) {

var o = "",

l = O + "=";

if (document.cookie.length > 0) {

var i = document.cookie.indexOf(l);

if (i != -1) {

i += l.length;

var I = document.cookie.indexOf(";", i);

if (I == -1) I = document.cookie.length;

o = unescape(document.cookie.substring(i, I))

}

};

return o

},

writeCookie: function(i, l, o, c) {

var O = "",

I = "";

if (o != null) {

O = new Date((new Date).getTime() + o * 3600000);

O = "; expires=" + O.toGMTString()

};

if (c != null) {

I = ";domain=" + c

};

document.cookie = i + "=" + escape(l) + O + I

},

readStyle: function(I, l) {

if (I.style[l]) {

return I.style[l]

} else if (I.rentStyle) {

return I.currentStyle[l]

} else if (document.defaultView && document.defaultView.getComputedStyle) {

var i = document.defaultView.getComputedStyle(I, null);

return i.getPropertyValue(l)

} else {

return null

}

}

};

function ScrollPic(scrollContId, arrLeftId, arrRightId, dotListId) {

this.scrollContId = scrollContId;

this.arrLeftId = arrLeftId;

this.arrRightId = arrRightId;

this.dotListId = dotListId;

this.dotClassName = "dotItem";

this.dotOnClassName = "dotItemOn";

this.dotObjArr = [];

this.pageWidth = 0;

this.frameWidth = 0;

this.speed = 10;

this.space = 10;

this.pageIndex = 0;

this.autoPlay = true;

this.autoPlayTime = 5;

var _autoTimeObj

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值