一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

javascript 不間斷的圖片滾動(dòng)并可點(diǎn)擊

css:
復(fù)制代碼 代碼如下:
<style type="text/css">
.rollBox
{
width: 704px;
overflow: hidden;
padding: 12px 0 5px 6px;
}
.rollBox .LeftBotton
{
height: 52px;
width: 19px;
background: url(jt.gif) no-repeat 11px 0;
overflow: hidden;
float: left;
display: inline;
margin: 25px 0 0 0;
cursor: pointer;
background-color:Blue;
color:White;
}
.rollBox .RightBotton
{
height: 52px;
width: 20px;
background: url(jt.gif) no-repeat -8px 0;
overflow: hidden;
float: left;
display: inline;
margin: 25px 0 0 0;
cursor: pointer;
background-color:Blue;
color:White;
}
.rollBox .Cont
{
width: 663px;
overflow: hidden;
float: left;
}
.rollBox .ScrCont
{
width: 10000000px;
}
.rollBox .Cont .pic
{
width: 132px;
float: left;
text-align: center;
}
.rollBox .Cont .pic img
{
padding: 4px;
background: #fff;
border: 1px solid #ccc;
display: block;
margin: 0 auto;
}
.rollBox .Cont .pic p
{
line-height: 26px;
color: #505050;
}
.rollBox .Cont a:link, .rollBox .Cont a:visited
{
color: #626466;
text-decoration: none;
}
.rollBox .Cont a:hover
{
color: #f00;
text-decoration: underline;
}
.rollBox #List1, .rollBox #List2
{
float: left;
}
</style>

html代碼
復(fù)制代碼 代碼如下:
<div class="rollBox">
<div class="LeftBotton" onmousedown="ISL_GoUp()" onmouseup="ISL_StopUp()" onmouseout="ISL_StopUp()">
<<<<<
</div>

<div class="Cont" id="ISL_Cont">
<div class="ScrCont">
<div id="List1">
<!-- 圖片列表 begin -->
<div class="pic">
<a href="####">
<img src="http://www.jb51.NET/images/logo.gif" width="109" height="87" /></a>
<a href="####">商品1</a>
</div>
<div class="pic">
<a href="####">
<img src="http://www.baidu.com/img/baidu_logo.gif" width="109" height="87" /></a>
<a href="####">商品2</a>
</div>
<div class="pic">
<a href="####">
<img src="http://www.baidu.com/img/baidu_logo.gif" width="109" height="87" /></a>
<a href="####">商品3</a>
</div>
<div class="pic">
<a href="####">
<img src="http://www.baidu.com/img/baidu_logo.gif" width="109" height="87" /></a>
<a href="####">商品4</a>
</div>
<div class="pic">
<a href="####">
<img src="http://www.baidu.com/img/baidu_logo.gif" width="109" height="87" /></a>
<a href="####">商品5</a>
</div>
<div class="pic">
<a href="####">
<img src="http://www.baidu.com/img/baidu_logo.gif" width="109" height="87" /></a>
<a href="####">商品6</a>
</div>
<div class="pic">
<a href="####">
<img src="http://www.baidu.com/img/baidu_logo.gif" width="109" height="87" /></a>
<a href="####">商品7</a>
</div>
<!-- 圖片列表 end -->
</div>
<div id="List2">
</div>
</div>
</div>

<div class="RightBotton" onmousedown="ISL_GoDown()" onmouseup="ISL_StopDown()" onmouseout="ISL_StopDown()">
>>>>>>
</div>
</div>

JS代碼
復(fù)制代碼 代碼如下:
//速度(毫秒)
var Speed = 10;
//每次移動(dòng)(px)
var Space = 5;
//每次翻頁(yè)寬度
var PageWidth = 132;
//整體移位(px)
var fill = 0;
//是否自動(dòng)移動(dòng),true 移動(dòng),false 不移動(dòng)
var MoveLock = false;
//移動(dòng)時(shí)間對(duì)象
var MoveTimeObj;
//上翻 下翻 變量,當(dāng)comp小于0 為上翻動(dòng) 反之為下翻動(dòng)
var Comp = 0;
//上下移動(dòng)對(duì)象
var AutoPlayObj = null;
//將div List1中的所有元素分配給 div list2中
GetObj("List2").innerHTML = GetObj("List1").innerHTML;
//向左移動(dòng)
GetObj('ISL_Cont').scrollLeft = fill;
//給div ISL_Cont 綁定鼠標(biāo)移動(dòng)在div上方時(shí)候的事件,該事件是清除自動(dòng)播放的,當(dāng)鼠標(biāo)移動(dòng)到div圖片上時(shí)候?qū)⑷∠詣?dòng)播放
GetObj("ISL_Cont").onmouseover = function(){ clearInterval(AutoPlayObj); }
//給div ISL_Cont 綁定鼠標(biāo)移開(kāi)div上方時(shí)候的時(shí)間,該事件是綁定自動(dòng)播放的,當(dāng)鼠標(biāo)移開(kāi)div圖片上時(shí)候?qū)⒂珠_(kāi)始自動(dòng)時(shí)間間隔自動(dòng)播放
GetObj("ISL_Cont").onmouseout = function(){ AutoPlay();}
//第一次進(jìn)來(lái)默認(rèn)綁定為自動(dòng)播放
AutoPlay();
/*
獲取指定html對(duì)象
*/
function GetObj(objName){
//判斷當(dāng)前頁(yè)面中是否存在有效的元素標(biāo)記,document.getElementById兼容火狐
if(document.getElementById)
{
return eval('document.getElementById("'+objName+'")')
}
else
{
return eval('document.all.'+objName)
}
}
/*
自動(dòng)滾動(dòng)
*/
function AutoPlay(){
//清除以前綁定的間隔時(shí)間滾動(dòng)
clearInterval(AutoPlayObj);
//重新綁定間隔時(shí)間滾動(dòng),setInterval()方法是綁定在指定的時(shí)間執(zhí)行,clearInterval()方法是清除指定的時(shí)間綁定對(duì)象
AutoPlayObj = setInterval('ISL_GoDown();ISL_StopDown();',5000);
}
/*
上翻開(kāi)始
*/
function ISL_GoUp(){
//如過(guò)當(dāng)前為自動(dòng)播放將不執(zhí)行下面代碼
if(MoveLock)
return;
//清除以前綁定的間隔時(shí)間滾動(dòng)
clearInterval(AutoPlayObj);
MoveLock = true;
//在指定的時(shí)間中自動(dòng)往左側(cè)移動(dòng)
MoveTimeObj = setInterval('ISL_ScrUp();',Speed);
}
/*
上翻停止
*/
function ISL_StopUp(){
//清除以前綁定的間隔時(shí)間滾動(dòng)
clearInterval(MoveTimeObj);
//判斷當(dāng)前論顯圖片的div做邊的變距是否是第一個(gè)商品圖片,不等于0不是第一個(gè),反之等于第一張圖片
if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0)
{
//div左邊距移動(dòng)
Comp = fill - (GetObj('ISL_Cont').scrollLeft % PageWidth);
//開(kāi)始移動(dòng)
CompScr();
}else
{
MoveLock = false;
}
//自動(dòng)播放
AutoPlay();
}
/*
上翻動(dòng)作
*/
function ISL_ScrUp(){
//如過(guò)當(dāng)前圖片的大div左邊距小于0那么它的邊距等于自身邊距加上左邊的點(diǎn)擊按鈕的寬度
if(GetObj('ISL_Cont').scrollLeft <= 0)
{
GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft + GetObj('List1').offsetWidth;
}
//往左側(cè)移動(dòng)
GetObj('ISL_Cont').scrollLeft -= Space ;
}
/*
下翻
*/
function ISL_GoDown(){
//清除以前綁定的間隔時(shí)間滾動(dòng)
clearInterval(MoveTimeObj);
//如過(guò)當(dāng)前為自動(dòng)播放將不執(zhí)行下面代碼
if(MoveLock)
return;
//清除自動(dòng)播放
clearInterval(AutoPlayObj);
MoveLock = true;
//下翻方法
ISL_ScrDown();
//在指定的時(shí)間中自動(dòng)往右側(cè)移動(dòng)
MoveTimeObj = setInterval('ISL_ScrDown()',Speed);
}
/*
下翻停止
*/
function ISL_StopDown(){
//清除以前綁定的間隔時(shí)間滾動(dòng)
clearInterval(MoveTimeObj);
//如過(guò)當(dāng)前圖片的大div左邊距小于0那么它的邊距等于自身邊距加上左邊的點(diǎn)擊按鈕的寬度
if(GetObj('ISL_Cont').scrollLeft % PageWidth - fill != 0 )
{
Comp = PageWidth - GetObj('ISL_Cont').scrollLeft % PageWidth + fill;
CompScr();
}else
{
MoveLock = false;
}
//開(kāi)始自動(dòng)播放
AutoPlay();
}
/*
下翻動(dòng)作
*/
function ISL_ScrDown(){
if(GetObj('ISL_Cont').scrollLeft >= GetObj('List1').scrollWidth)
{
GetObj('ISL_Cont').scrollLeft = GetObj('ISL_Cont').scrollLeft - GetObj('List1').scrollWidth;
}
GetObj('ISL_Cont').scrollLeft += Space;
}
/*
左右移動(dòng)控制處理
*/
function CompScr(){
var num;
if(Comp == 0)
{
MoveLock = false;
return;
}
//上翻
if(Comp < 0)
{
if(Comp < -Space)
{
Comp += Space;
num = Space;
}else
{
num = -Comp;
Comp = 0;
}
GetObj('ISL_Cont').scrollLeft -= num;
setTimeout('CompScr()',Speed);
}else //下翻
{
if(Comp > Space)
{
Comp -= Space;
num = Space;
}else
{
num = Comp;
Comp = 0;
}
GetObj('ISL_Cont').scrollLeft += num;
setTimeout('CompScr()',Speed);
}
}

JavaScript技術(shù)javascript 不間斷的圖片滾動(dòng)并可點(diǎn)擊,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 深爱五月激情网 | riav久久中文一区二区 | 两性午夜刺激性视频 | www.av在线.com | 伊人草草| 美女被性调教视频在线观看 | 激情在线网站 | 色网址在线 | 亚洲欧美日韩在线精品一区二区 | 天天摸天天看天天爽 | 免费看黄色的视频 | 国产精品视频一 | 成人美女黄网站色大色费 | 久久精品中文字幕久久 | 国产午夜大片 | 911国内自产亚洲第一 | 日韩欧美精品一区二区三区 | 青草社区在线 | 伊人精品国产 | 欧美日韩视频在线第一区二区三区 | 国产视频久 | 久久青草免费91线频观看站街 | 国产精品免费看久久久麻豆 | 成人免费小视频 | 久久福利网 | 国产福利在线 | 国产一区二区自拍视频 | 国产精品欧美激情在线播放 | 4399一级成人毛片 | 激性欧美在线播激性欧美 | 一木道一二三区精品 | 真实国产乱子伦精品免费 | 激情美女网站 | 伊人狼人综合网 | 天天色图片 | 免费视频精品 | 国产色婷婷精品综合在线 | 一本三道a无线码一区v小说 | 91激情| 欧美色成人 | 一区二区三区四区五区六区 |