<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function dp(txtInput) {
            this.test = document.getElementById(txtInput);
            this.score = 80;
            if (typeof lock == "undefined") {                dp.prototype.init = function () {
                    this.test.onkeyup = this.suggest;
                }
                dp.prototype.suggest = function (event) {
                    var obj = window.event.srcElement || event.target;
                    alert(obj.value);
                    alert(this);  //这个地方输出的是input 我要怎么样在这个方法种用 构造的这个对象调用此对象种其他属性和方法 比如score和getvalue()  
                }
               dp.prototype.getvalue = function(){ }
               
                var lock = true;
            }
        }        window.onload = function () {
            var input1 = new dp("test");
            input1.init();
        }
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="text" id="test" />
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   

      function dp(txtInput) {
      this.test = document.getElementById(txtInput);
      this.score = 80;
      if (typeof lock == "undefined") {  dp.prototype.init = function () {
      this.test.onkeyup = function(){
               var o = this
               return function(e){ o.suggest(e)};
           }.call(this)

      }
      dp.prototype.suggest = function (event) {
      event = window.event || event
      var obj = event.srcElement || event.target;
      alert(obj.value);
      alert(this); //这个地方输出的是input 我要怎么样在这个方法种用 构造的这个对象调用此对象种其他属性和方法 比如score和getvalue() 
      }
      dp.prototype.getvalue = function(){ }
        
      var lock = true;
      }
      }  window.onload = function () {
      var input1 = new dp("test");
      input1.init();
      }
      

  2.   

    “大嘴哥”的代码估计LZ看着晕 给LZ来个简单易懂的~~
    function dp(txtInput) {
    this.test = document.getElementById(txtInput);
    this.score = 80;
    if (typeof lock == "undefined") { dp.prototype.init = function() {
    var me = this; //将this指代提出
    this.test.onkeyup = function() {
    me.suggest.call(me)
    }
    } dp.prototype.suggest = function(event) {
    var obj = window.event.srcElement || event.target;
    alert(obj.value);
    alert(this.score);
    alert(this.getvalue());
    }
    dp.prototype.getvalue = function() {
    return "aaa" //在你的代码上加了句话 呵呵 调试用
    } var lock = true; }
    }
      

  3.   

    谢谢二位 对于this还是有点迷糊