本帖最后由 goukili 于 2010-06-25 14:44:43 编辑

解决方案 »

  1.   

    如果你用的是NEW dragtest()
    那么你就需要这么调用 VAR TEST=NEW dragtest();
    document.onmouseover = dragtest.moveit();
    否则请将调用函数的那个()带上还有那个参数E
    你只声明了THIS.moveit()没有THIS.moveit
    document.onmouseover = this.moveit();
      

  2.   

    你有写onmousemove事件的处理函数吗?
    document.onmousemove=???
      

  3.   

    document.onmouseover 是先于onmousedown发生的,扑捉移动用onmousemove
      

  4.   


        var dragtestobj = new dragtest();
        dragtestobj.initialize();
    我是这样实例化对象地。我并没有要直接调用this.moveit方法!
    而是打算把该方法赋值给 document.onmouseover 让这个事件来调用,触发的时候自动调用!
      

  5.   

    好吧,也许是我学艺不精
        function dragtest() {
        }
        dragtest.prototype.initialize = function() {
            document.onmousedown = this.drag(e);//考虑下这个E怎么传
            document.onmouseup = function() {
                alert("onmouseup");
            }
        }
        dragtest.prototype.drag = function(e) {
                alert("drag");
                document.onmouseover = this.moveit(e);
        }
        dragtest.prototype.moveit = function(e) {
                alert("moveit");
        }
      

  6.   

    function dragtest() {
        }
        dragtest.prototype.initialize = function() {
            document.onmousedown = this.drag;
            document.onmouseover = this.moveit;
            document.onmouseup = function() {
                alert("onmouseup");
            }
        }
        dragtest.prototype.drag = function(e) {
                alert("drag");
        }
        dragtest.prototype.moveit = function(e) {
                alert("moveit");
        }
    我将document.onmouseover = this.moveit; 移到dragtest.prototype.initialize中就能正确找到moveit方法,为什么放在dragtest.prototype.drag中就出错,说尚未实现
      

  7.   

    我可以把e去掉,完全不用的,这个和参数e没有任何关系。    function dragtest() {
        }
        dragtest.prototype.initialize = function() {
            document.onmousedown = this.drag;
            document.onmouseup = function() {
                alert("onmouseup");
            }
        }
        dragtest.prototype.drag = function() {
                alert("drag");
                document.onmouseover = this.moveit;
        }
        dragtest.prototype.moveit = function() {
                alert("moveit");
        }
      

  8.   

    知道原因了
    var dragtestobj = new dragtest();
    dragtestobj.initialize();实例化对象并调用initialize时候,事件对象是实例对象dragtestobjdragtest.prototype.initialize = function() {
            document.onmousedown = this.drag;
            document.onmouseup = function() {
                alert("onmouseup");
            }
        }所以此处document.onmousedown = this.drag;,this指的是 dragtestobj而当鼠标移动触发document.onmousedown事件是的事件源是document
        dragtest.prototype.drag = function() {
                alert("drag");
                document.onmouseover = this.moveit;
        }所以此处document.onmouseover = this.moveit;,this指的是 document,故document对象是没有moveit方法的。