好像有bug哦。多按几次。好像就停在那里左右晃动.不过等一次下就,没事了

解决方案 »

  1.   

    用ie6的确有问题向左移时,把鼠标放到"mcc"上,但不点击,在移开就会出现10楼的现象改成
    document.getElementById('mcc').onmouseout=function(){clearInterval(MyMar);MyMar=setInterval(RMarquee,speed3);} 
    document.getElementById('aa').onmouseout=function(){clearInterval(MyMar);MyMar=setInterval(Marquee,speed3);}初步测试就没问题了。
      

  2.   

    我在IE6里做的
    呵呵,竟然说IE6有问题,我测试你说的情况没发现。
      

  3.   

    刚注意看了下我本地的正常的文件,才发现跟我帖的这个代码少了
    你说的这document.getElementById('mcc').onmouseout=function(){clearInterval(MyMar);MyMar=setInterval(RMarquee,speed3);} 
    document.getElementById('aa').onmouseout=function(){clearInterval(MyMar);MyMar=setInterval(Marquee,speed3);} 
    红色部分
      

  4.   

    别的暂不做评价,但看出来楼主的html代码写的很烂~~~
      

  5.   

    .......我都不写HTML代码的,那段html代码直接复制别人的来测试我的JS
      

  6.   

    测试JS用的,就不管他规范不规范了主要是体现我的JS正常使用
      

  7.   

    你的html:
    1.大小写不一致,参照xhtml1-strict,标签都应该是小写的。
    2.应用了center过时的元素
    3.td里面嵌套div,只为了让文字居中
    4.body里面应用了过时的元素。在这里不是来指责你的不足,而是想要你明白,在前端程序中,html是骨架,一定得写好了。html写好了,才能写出更漂亮,更高效的css,javascript.
      

  8.   

    原理很简单,希望楼主写的对大家有所帮助。
    我这里也有段代码,在这里提供大家参考:<!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" />
    <title>JavaScript 无缝上下(左右)滚动加定高(定宽)停顿效果(兼容ie/ff)</title>
    </head>
    <body>
    <script type="text/javascript">
    var $ = function (id) {
        return "string" == typeof id ? document.getElementById(id) : id;
    };var Class = {
      create: function() {
        return function() {
          this.initialize.apply(this, arguments);
        }
      }
    }Object.extend = function(destination, source) {
        for (var property in source) {
            destination[property] = source[property];
        }
        return destination;
    }function addEventHandler(oTarget, sEventType, fnHandler) {
        if (oTarget.addEventListener) {
            oTarget.addEventListener(sEventType, fnHandler, false);
        } else if (oTarget.attachEvent) {
            oTarget.attachEvent("on" + sEventType, fnHandler);
        } else {
            oTarget["on" + sEventType] = fnHandler;
        }
    };
    var Scroller = Class.create();
    Scroller.prototype = {
      initialize: function(idScroller, idScrollMid, options) {
        var oScroll = this, oScroller = $(idScroller), oScrollMid = $(idScrollMid);
        
        this.SetOptions(options);
        this.Scroller = oScroller;    
        this.Speed = this.options.Speed;
        this.timer = null;
        this.Pause = 0;
        
        //用于上下滚动
        this.heightScroller = parseInt(oScroller.style.height) || oScroller.offsetHeight;
        this.heightList = oScrollMid.offsetHeight;
        
        //用于左右滚动
        this.widthScroller = parseInt(oScroller.style.width) || oScroller.offsetWidth;
        this.widthList = oScrollMid.offsetWidth;
        
        //js取不到css设置的height和width
        
        oScroller.style.overflow = "hidden";
        oScrollMid.appendChild(oScrollMid.cloneNode(true));
        
        //方向设置
        switch (this.options.Side.toLowerCase()) {
            case "right" :
                if(this.widthList <= this.widthScroller) return;
                this.Scroll = this.ScrollLeftRight;
                this.side = -1;
                break;
            case "left" :
                if(this.widthList <= this.widthScroller) return;
                this.Scroll = this.ScrollLeftRight;
                this.side = 1;
                break;
            case "down" :
                if(this.heightList <= this.heightScroller) return;
                this.Scroll = this.ScrollUpDown;
                this.side = -1;
                break;
            case "up" :
            default :
                if(this.heightList <= this.heightScroller) return;
                this.Scroll = this.ScrollUpDown;
                this.side = 1;
        }
        
        addEventHandler(oScroller, "mouseover", function() { oScroll.Stop(); });
        addEventHandler(oScroller, "mouseout", function() { oScroll.Start(); });
        
        this.Start();
      },
      //设置默认属性
      SetOptions: function(options) {
        this.options = {//默认值
          Step:            1,//每次变化的px量
          Speed:        20,//速度(越大越慢)
          Side:            "up",//滚动方向:"up"是上,"down"是下,"left"是左,"right"是右
          PauseHeight:    0,//隔多高停一次
          PauseWidth:    0,//隔多宽停一次
          PauseStep:    1000//停顿时间(PauseHeight或PauseWidth大于0该参数才有效)
        };
        Object.extend(this.options, options || {});
      },  
      //上下滚动
      ScrollUpDown: function() {
        this.Scroller.scrollTop = this.GetScroll(this.Scroller.scrollTop, this.heightScroller, this.heightList, this.options.PauseHeight);
        
        var oScroll = this;
        this.timer = window.setTimeout(function(){ oScroll.Scroll(); }, this.Speed);
      },
      //左右滚动
      ScrollLeftRight: function() {
        //document.getElementById("test").innerHTML+=iStep+",";
        //注意:scrollLeft超过1400会自动变回1400 注意长度
        this.Scroller.scrollLeft = this.GetScroll(this.Scroller.scrollLeft, this.widthScroller, this.widthList, this.options.PauseWidth);
        
        var oScroll = this;
        this.timer = window.setTimeout(function(){ oScroll.Scroll(); }, this.Speed);
      },
      //获取设置滚动数据
      GetScroll: function(iScroll, iScroller, iList, iPause) {
        var oScroll = this, iStep = this.options.Step * this.side;
        
        if(this.side > 0){
            if(iScroll >= (iList * 2 - iScroller)){ iScroll -= iList; }
        } else {
            if(iScroll <= 0){ iScroll += iList; }
        }
        
        this.Speed = this.options.Speed;
        if(iPause > 0){
            if(Math.abs(this.Pause) >= iPause){
                this.Speed = this.options.PauseStep; this.Pause = iStep = 0;
            } else {
                this.Pause += iStep;
            }
        }
        
        return (iScroll + iStep);
      },
      //开始
      Start: function() {
        this.Scroll();
      },
      //停止
      Stop: function() {
        clearTimeout(this.timer);
      }
    };window.onload = function(){
        new Scroller("idScroller", "idScrollMid",{ Side:"up", PauseHeight:25 });
        new Scroller("idScroller1", "idScrollMid1",{ Side:"right", PauseWidth:250, Speed:10 });
    }
    </script>
    <style>
    .Scroller *{}{margin:0px; padding:0px;}
    .Scroller {}{line-height:25px;overflow:hidden; border:1px solid #000000;}#idScrollMid ul{}{width:500px;}
    #idScrollMid li{}{width:250px;float:left; overflow:hidden; list-style:none;}#idScrollMid1 {}{float:left;}
    #idScrollMid1 ul{}{width:250px;float:left;overflow:hidden;}
    #idScrollMid1 li{}{list-style:none;}
    </style>
    <div id="idScroller" class="Scroller" style="width:500px; height:50px;">
      <div id="idScrollMid">
        <ul>
          <li><a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          <li><a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          <li><a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          <li><a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          <li><a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          <li><a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
        </ul>
        <div style="clear:both;"></div>
      </div>
    </div>
    <br />
    <br />
    <br />
    <div id="idScroller1" class="Scroller" style="width:500px; height:50px;">
      <div style="width:2000px">
        <div id="idScrollMid1">
          <ul>
            <li> <a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
            <li> <a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          </ul>
          <ul>
            <li> <a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
            <li> <a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          </ul>
          <ul>
            <li> <a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
            <li> <a href="http://www.scriptlover.com/">by the way,have a nice day for you. </a></li>
          </ul>
        </div>
      </div>
    </div>
    <div id="test"></div>
    </body>
    </html>http:www.scriptlover.com
      

  9.   

    哈哈 chinmo大哥 痴情客整个clou兄的代码 来忽悠你呢
      

  10.   

    我研究你这个东西一上午了
    我就是在VS2005里
    建立一个ASPX页
    在其源里面
    把BODY部分替换成你博客里的东西查看设计页看不了
    只能看源,程序运行起来
    怎么点都不好用,并且只显示向左 向右怎么点都不好用
      

  11.   


    呵呵,真疏忽了,
    <DIV id=demo style="OVERFLOW: hidden; WIDTH: 100%; COLOR: #ffffff"> 
    这个还跟我本地的不一样
    难怪你们说的我测试都没问题
    应该改成<DIV id=demo style="OVERFLOW: hidden; WIDTH: 750; COLOR: #ffffff">
      

  12.   

    应该是<DIV id=demo style="OVERFLOW: hidden; WIDTH: 750px; COLOR: #ffffff">
      

  13.   

    不能用呀!IE6,FF2.0.0.16,看不到效果
      

  14.   


    看完后面的回复,因为CSDN没有修改的,没办法
    我第一次帖的是错误的,复制错了代码,但已经没法修改了