大家对这块肯定已经很熟悉了。滚动是上下翻滚的。
如何修改为左右连续滚呢!!!
这个是js代码- //垂直滚动 格式:new zjScroll("标记ID",每次滚动高度(px),滚动速度(ms),间隔时间(ms));
- function zjScroll(){
- this.id = arguments[0];
- if(this.id == null) this.id = "";
- this.height = arguments[1];
- if(this.height == null) this.height = 20;
- this.speed = arguments[2];
- if(this.speed == null) this.speed = 20;
- this.delay = arguments[3];
- if(this.delay == null) this.delay = 2000;
- this.ispause = false;
- this.sctop = 0;
- this.step = 0;
- this.flag = true;
- var idcnt;
- if(!(this.id == "")){
- idcnt = $(this.id).innerHTML;
- $(this.id).innerHTML = "<table border="0" cellspacing="0" cellpadding="0"><tr><td id="" + this.id + "_S1">" + idcnt + "</td></tr><tr><td id="" + this.id + "_S2">" + idcnt + "</td></tr></table>";
- this.init();
- }
- }
- zjScroll.prototype.init = function(){
- var myobj = this;
- $(myobj.id).scrollTop = 0;
- myobj.Scroll = function(){
- $(myobj.id).onmouseover = function(){
- myobj.ispause = true;
- }
- $(myobj.id).onmouseout = function(){
- myobj.ispause = false;
- }
- if(myobj.flag){
- myobj.flag = false;
- if(myobj.sctop >= $(myobj.id+"_S1").offsetHeight){
- myobj.sctop = myobj.sctop - $(myobj.id+"_S1").offsetHeight;
- $(myobj.id).scrollTop = myobj.sctop;
- }
- setTimeout(myobj.Scroll, myobj.delay);
- return true;
- }
- if(!myobj.ispause){
- myobj.sctop++;
- myobj.step++;
- $(myobj.id).scrollTop = myobj.sctop;
- if(myobj.step == myobj.height){
- myobj.step = 0;
- myobj.flag = true;
- }
- }
- setTimeout(myobj.Scroll, myobj.speed);
- }
- myobj.Scroll();
- }
复制代码 这个是调用代码:- <div id="infobox" align="center"><!--通知通告开始-->
- <div id="anc">
- <!--{block name="announcement" parameter="order/displayorder DESC/limit/0,15/cachetime/6/subjectlen/30/cachename/gg/tpl/tztg"}--><!--gg-->
- </div>
- <script language="javascript" type="text/javascript">new zjScroll("anc",21,20,2000);</script>
- </div><!--通知通告结束-->
复制代码 请高手指点迷津! |