JS幻灯片-实现多屏切换效果轮播滚动特效代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 JS幻灯片-实现多屏切换效果轮播滚动特效代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

JS幻灯片-实现多屏切换效果轮播滚动特效代码

HTML代码(index.html):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="JS代码,{keyword},JS广告代码,JS特效代码" />
<meta name="description" content="此代码内容为{title},属于站长常用代码" />
<title>{title}</title>
<link rel="stylesheet" type="text/css" href="css/lrtk.css" />
<script type="text/javascript" src="js/pptBox.js"></script>
</head>
<body>
<div id="xxx"  >
     <script>
     var box =new PPTBox();
     box.width = 600; //宽度
     box.height = 295;//高度
     box.autoplayer = 3;//自动播放间隔时间

     //box.add({"url":"图片地址","title":"悬浮标题","href":"链接地址"})
     box.add({"url":"images/tu1.jpg","href":"#","title":"悬浮提示标题1"})
     box.add({"url":"images/tu2.jpg","href":"#","title":"悬浮提示标题2"})
     box.add({"url":"images/tu3.jpg","href":"#","title":"悬浮提示标题3"})
     box.add({"url":"images/tu4.jpg","href":"#","title":"悬浮提示标题4"})
     box.show();
    </script>
</div>
</body>
</html>

JS代码(pptBox.js):

 /** * PPT ���� * ������ 2012-05-17 */
 function PPTBox(){
	this.uid = PPTBoxHelper.getId();
	PPTBoxHelper.instance[this.uid] = this;
	this._$ = function(id){
	return document.getElementById(id);
}
;
	this.width = 400;
	//��� this.height = 300;
	//�߶� this.picWidth = 15;
	//Сͼ��� this.picHeight = 12;
	//Сͼ�߶� this.autoplayer = 4;
	//�Զ����ż����룩 this.target = "_blank";
	this._box = [];
	this._curIndex = 0;
}
PPTBox.prototype ={
	_createMainBox:function (){
	var flashBoxWidth = this.width * this._box.length + 5;
	var html="<div id='"+this.uid+"_mainbox' class='mainbox' style='width:"+(this.width)+"px;
	height:"+(this.height+2)+"px;
	'>";
	html += "<div id='"+this.uid+"_flashbox' class='flashbox' style='width:"+flashBoxWidth+"px;
	height:"+(this.height+2)+"px;
	'></div>";
	html += "<div id='"+this.uid+"_imagebox' class='imagebox' style='width:"+this.width+"px;
	height:"+(this.picHeight+2)+"px;
	top:-"+(this.picHeight+20)+"px;
	'></div>";
	html += "</div>";
	document.write(html);
}
,_init:function (){
	var picstyle= "";
	var eventstr = "PPTBoxHelper.instance['"+this.uid+"']";
	var imageHTML="";
	var flashbox = "";
	for(var i=0;
	i<this._box.length;
	i++){
	var parame = this._box[i];
	flashbox += this.flashHTML(parame.url,this.width,this.height,i);
	imageHTML ="<div class='bitdiv "+((i==0)?"curimg":"defimg")+"' title ="+parame.title+" src='bit01.gif' "+picstyle+" onclick = \""+eventstr+".clickPic("+i+")\" onmouseover=\""+eventstr+".mouseoverPic("+i+")\"></div>" + imageHTML;
}
this._$(this.uid+"_flashbox").innerHTML = flashbox;
	this._$(this.uid+"_imagebox").innerHTML = imageHTML;
}
,_play:function(){
	clearInterval(this._autoplay);
	var idx = this._curIndex+1;
	if(idx>=this._box.length){
	idx=0;
}
this.changeIndex(idx);
	var eventstr = "PPTBoxHelper.instance['"+this.uid+"']._play()";
	this._autoplay = setInterval(eventstr,this.autoplayer*1000);
}
,flashHTML:function(url,width,height,idx){
	var isFlash = url.substring(url.lastIndexOf('.')+1).toLowerCase()=="swf";
	var html = "";
	if(isFlash){
	html = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' " + "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+width+"' height='"+height+"'>" + "<param name=\"movie\" value=\""+url+"\" />" + "<param name='quality' value='high' />" + "<param name='wmode' value='transparent'>" + "<embed src='"+url+"' quality='high' wmode='opaque' pluginspage='http://www.macromedia.com/go/getflashplayer'" +" type='application/x-shockwave-flash' width="+width+" height='"+height+"'></embed>" +" </object>";
}
else{
	var eventstr = "PPTBoxHelper.instance['"+this.uid+"']";
	var style = "";
	if(this._box[idx].href){
	style = "cursor:pointer"}
html="<img src='"+url+"' style='width:"+width+"px;
	height:"+height+"px;
	"+style+"' onclick = \""+eventstr+".clickPic("+idx+")\"/>";
}
return html;
}
,changeIndex:function(idx){
	var parame = this._box[idx];
	moveElement(this.uid+"_flashbox",-(idx*this.width),1);
	var imgs = this._$(this.uid+"_imagebox").getElementsByTagName("div");
	imgs[this._box.length-1-this._curIndex].className = "bitdiv defimg";
	imgs[this._box.length-1-idx].className = "bitdiv curimg";
	this._curIndex = idx;
}
,mouseoverPic:function(idx){
	this.changeIndex(idx);
	if(this.autoplayer>0){
	clearInterval(this._autoplay);
	var eventstr = "PPTBoxHelper.instance['"+this.uid+"']._play()";
	this._autoplay = setInterval(eventstr,this.autoplayer*1000);
}
}
,clickPic:function(idx){
	var parame = this._box[idx];
	if(parame.href&&parame.href!=""){
	window.open(parame.href,this.target);
}
}
,add:function (imgParam){
	this._box[this._box.length] = imgParam;
}
,show:function (){
	this._createMainBox();
	this._init();
	if(this.autoplayer>0){
	var eventstr = "PPTBoxHelper.instance['"+this.uid+"']._play()";
	this._autoplay = setInterval(eventstr,this.autoplayer*1000);
}
}
}
var PPTBoxHelper ={
	count:0,instance:{
}
,getId:function(){
	return '_ppt_box-' + (this.count++);
}
}
;
	function moveElement(elementID,final_x,interval){
	if (!document.getElementById) return false;
	if (!document.getElementById(elementID)) return false;
	var elem = document.getElementById(elementID);
	if (elem.movement){
	clearTimeout(elem.movement);
}
if (!elem.style.left){
	elem.style.left = "0px";
}
var xpos = parseInt(elem.style.left);
	if (xpos == final_x ){
	return true;
}
if (xpos < final_x){
	var dist = Math.ceil((final_x - xpos)/5);
	xpos = xpos + dist;
}
if (xpos > final_x){
	var dist = Math.ceil((xpos - final_x)/5);
	xpos = xpos - dist;
}
elem.style.left = xpos + "px";
	var repeat = "moveElement('"+elementID+"',"+final_x+","+interval+")";
	elem.movement = setTimeout(repeat,interval);
}

CSS代码(lrtk.css):

.mainbox{overflow:hidden;position:relative;}
.flashbox{overflow:hidden;position:relative;}
.imagebox{text-align:right;position:relative;z-index:999;}
.bitdiv{display:inline-block;width:18px;height:18px;margin:0 10px 10px 0px;cursor:pointer;float:right;}
.defimg{background-image:url(../images/02.png)}
.curimg{background-image:url(../images/01.png)}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
200.13 KB
Html 焦点滚动特效1
最新结算
股权转让协议意向书模板
类型: .docx 金额: CNY 2.23¥ 状态: 待结算 详细>
股权转让协议意向书模板
类型: .docx 金额: CNY 0.28¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 2.39¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 0.3¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章