function floaters() {
  this.items = [];
  this.addItem = function(id,x,y,content)
      {
     document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute;width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
    
     var newItem    = {};
     newItem.object   = document.getElementById(id);
     newItem.x    = x;
     newItem.y    = y;     this.items[this.items.length]  = newItem;
      }
  this.play = function()
      {
     collection    = this.items
     setInterval('play()',30);
      }
  }
这里this.items = [];是什么意思?this.items[this.items.length] 这里this.items.length是多少?
2this.play = function(){}和function play(){}什么区别的?

解决方案 »

  1.   

    这里this.items = [];是什么意思?
    //定义一个空数组
    this.items[this.items.length] 这里this.items.length是多少?
    //这个数组的长度,这句话表示给这个数组添加一个元素
    this.play = function(){}和function play(){}什么区别的?
    //this.play = function.. 表示给当前类添加一个方法,另外一个是定义一个函数
      

  2.   

    这是类似于面向对象语言的类和方法以及属性的写法
    另外:这个样写定义了过多的实例方法,用prototype定义方法原型应该更节省内存空间。
      

  3.   

    this.items[this.items.length] 这里this.items.length是多少? 
    //这个数组的长度,这句话表示给这个数组添加一个元素
    ----------
    那就是this.items.length=0?
      

  4.   

    这里定义了一个floaters类,其中有一个属性是items 他是一个数组,没有初值,addItem 和play 是这个类的两个方法
    addItem 方法用来生成div对象,并把对象储存在items 属性中,div的id,及left top style属性由形参给出
    div的内容也由形参给出
    play方法是把生成的div对象数组付给collection    
    你的这段代码还有其他的马,贴出来看看
      

  5.   


     var delta=0.15;
    var collection;
    var closeB=false;
    var documentBody = document.documentElement.clientHeight>0 ? document.documentElement : document.body;function floaters() {
      this.items = [];
      this.addItem = function(id,x,y,content)
          {
         document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute;width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
        
         var newItem    = {};
         newItem.object   = document.getElementById(id);
         newItem.x    = x;
         newItem.y    = y;     this.items[this.items.length]  = newItem;
          }
      this.play = function()
          {
         collection    = this.items
         setInterval('play()',30);
          }
      }
      function play()
      {
       if(screen.width<=800 || closeB)
       {
        for(var i=0;i<collection.length;i++)
        {
         collection[i].object.style.display = 'none';
        }
        return;
       }
       for(var i=0;i<collection.length;i++)
       {
        var followObj  = collection[i].object;
        var followObj_x  = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
        var followObj_y  = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);
        if(followObj.offsetLeft!=(documentBody.scrollLeft+followObj_x)) {
         var dx=(documentBody.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
         dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
         followObj.style.left=(followObj.offsetLeft+dx) + "px";
         }    if(followObj.offsetTop!=(documentBody.scrollTop+followObj_y)) {
         var dy=(documentBody.scrollTop+followObj_y-followObj.offsetTop)*delta;
         dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
         followObj.style.top=(followObj.offsetTop+dy) + "px";
         }
        followObj.style.display = 'block';
       }
      }
      function closeBanner()
      {
       closeB=true;
       return;
      }var theFloaters  = new floaters();.大家来解释解释吧
      

  6.   

    这里的this.play = function()
    和function play()
    是一个玩意吗?
      

  7.   

    是一样的,在FUNCTION就相当与var,
    this.play=function().. 是直接量
      

  8.   

    function play()
    var play=function()
    var play=new Function{}
    三个都是一样的