本帖最后由 shenshuiyouhun 于 2010-09-24 14:42:03 编辑

解决方案 »

  1.   

    tag a 沒有結束的 </a>。問題到底是什麼?
      

  2.   

    <div id="nli_con">
    id重複了,ID是識別物件的key。
      

  3.   

    我不懂js代码.js代码部分的id,我不知道怎么修改.
      

  4.   


    <!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>无标题文档</title>
    <style type="text/css">
    <!--
    #nli_con {
    height: 36px;
    width: 400px;
    overflow: hidden;
    border: 1px solid #999999;
    line-height:36px;
    }
    div,dl,dt,dd {
    margin: 0px;
    padding: 0px;
    }
    dl {
    padding-top: 5px;
    padding-bottom: 5px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #CCCCCC;
    font-size: 14px;
    margin-right: 10px;
    margin-left: 10px;
    }
    dd {
    font-size: 12px;
    }
    -->
    </style>
    <script language="javascript">
    var $ = function (d){
        typeof d == "string" &&(d = document.getElementById(d)); 
        return $.fn.call(d);
    };
    $.fn = function (){//附加2个方法
    this.$ADD = function (fn){CLS.add(this,fn)};
    this.addEvent = function (sEventType,fnHandler){
    if (this.addEventListener) {this.addEventListener(sEventType, fnHandler, false);} 
        else if (this.attachEvent) {this.attachEvent("on" + sEventType, fnHandler);} 
        else {this["on" + sEventType] = fnHandler;}
    }
    this.removeEvent = function (sEventType,fnHandler){
    if (this.removeEventListener) {this.removeEventListener(sEventType, fnHandler, false);} 
        else if (this.detachEvent) {this.detachEvent("on" + sEventType, fnHandler);} 
        else { this["on" + sEventType] = null;}
    }
    return this;
    };
    var Class = {create: function() {return function() { this.initialize.apply(this, arguments); }}};
    var Bind = function (obj,fun,arr){return function() {return fun.apply(obj,arr);}}
    var Marquee = Class.create();
    Marquee.prototype = {
      initialize: function(id,name,out,speed) {
        this.name = name;
    this.box = $(id);
    this.out  = out;
    this.speed = speed;
    this.d = 1;
    this.box.style.position = "relative";
    this.box.scrollTop = 0;
    var _li = this.box.firstChild;
    while(typeof(_li.tagName)=="undefined")_li = _li.nextSibling;
    this.lis = this.box.getElementsByTagName(_li.tagName);
    this.len = this.lis.length;
    for(var i=0;i<this.lis.length;i++){//计算该复制多少节点,保证无缝滚动,没必要的就不复制
        var __li = document.createElement(_li.tagName);
    __li.innerHTML = this.lis[i].innerHTML;
    this.box.appendChild(__li);
    if(this.lis[i].offsetTop>=this.box.offsetHeight)break;
    }
    this.Start();
    this.box.addEvent("mouseover",Bind(this,function(){clearTimeout(this.timeout);},[]));
    this.box.addEvent("mouseout",Bind(this,this.Start,[]));
      },
      Start:function (){
      clearTimeout(this.timeout);
      this.timeout = setTimeout(this.name+".Up()",this.out*1000)
      },
      Up:function(){
      clearInterval(this.interval);
      this.interval = setInterval(this.name+".Fun()",10);
      },
      Fun:function (){
          this.box.scrollTop+=this.speed;
      if(this.lis[this.d].offsetTop <= this.box.scrollTop){
        clearInterval(this.interval);
    this.box.scrollTop = this.lis[this.d].offsetTop;
    this.Start();
    this.d++;
      }
      if(this.d >= this.len + 1){
         this.d = 1;
         this.box.scrollTop = 0;
      }
      }
    };
    $(window).addEvent("load",function (){
      marquee = new Marquee("nli_con","marquee",1,2);//加载完后运行代码,
    });
    </script>
    </head>
    <body>
     <div id="nli_con">
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>1</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>2</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>3</strong></div>
    </div> <div id="nli_con001">
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>1</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>2</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>3</strong></div>
    </div>
    </body>
    </html>div的id我改了,但是我不知道怎么修改js部分的代码,请高手指点.
      

  5.   

    两次出现<div id="nli_con">,两个id一样,肯定会有问题
      

  6.   

    试试把 
    $(window).addEvent("load",function (){
      marquee = new Marquee("nli_con","marquee",1,2);//加载完后运行代码,
    });
    加上
    $(window).addEvent("load",function (){
      marquee = new Marquee("nli_con","marquee",1,2);//加载完后运行代码,
    marquee = new Marquee("nli_con001","marquee",1,2);//加载完后运行代码
    });
    不知道是不是你要的效果
      

  7.   

    在js中修改:
    marquee = new Marquee("nli_con01","marquee",1,2);
    marquee = new Marquee("nli_con02","marquee",1,2);
    在html代码中修改:
    <div id="nli_con01">
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>1</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>2</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>3</strong></div>
    </div> <div id="nli_con02">
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>1</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>2</strong></div>
     <div><a href=http://www.hwj123.com/'blog/post/10.html' target='_blank'><strong>3</strong></div>
    </div>
      

  8.   

    改id   同页面不要出现重复id