Source:
Hao_roll = { id:null, speed:30, timer:null, num:0, olih:0 , alih:0, mouseon:false, json:null, // Initialize I Nit:function (obj) { This.json = {}; for (var i in obj) { This.json[i] = obj[i]; } This.onav = doc Ument.getelementbyid (this.json.id)// alert (this.oNav.parentNode); var aLi = this.oNav.getElementsByTagName (' li '); //Set style THIS.O nav.parentnode.style.position= "relative"; this.onav.style.position= ' absolute '; this.onav.style.left= ' 0 '; this.onav.style.top= ' 0 '; & nbsp for (var i=0; i<ali.length; i++) {&NBSp ali[i].style.float = ' left '; } TH Is.olih = ali[0].offsetheight; This.alih = this.olih*ali.length*2; T his.onav.innerhtml+=this.onav.innerhtml;// console.log (This.alih) }, / timer timer:function () { This.timer = setinterval (function () { Hao_roll. num--;// console.log (hao_roll. Num); if (hao_roll. Num<= (-HAO_ROLL.ALIH/2)) { Hao_roll. num=1; } Hao_roll.oNav.style.top = Hao_r Oll. num+ ' px ' },this.speed); }, // event execution ROLl:function (obj) {// console.log (obj); hao_roll.init (obj); & nbsp This.id = this.json.id; this.speed = this.json.speed; This.mouseon = this.json.mouseon; this. Timer (); if (This.mouseon) { Hao_roll.oNav.onmouseover = function () { Hao_roll.moseover (); &NBSP ; }; hao_roll.oNav.onmouseout = function () { &NBSP ; Hao_roll.moseout (); }; } &N Bsp }, //mouse move on clear timer moseover:function () { Clearinterval ( This.timer); }, //mouse move timer continue MoseoUt:function () { this. Timer () };
HTML code:
</pre><pre name= "code" class= "HTML" ><! DOCTYPE html>
Scroll up and down the carousel bar