修改如下。。
:D
function jsTable(gSerchBox,tblName,gHid)
    {
var wc = this;
        wc.tblName = "aaa";
        wc.gInputbox = gSerchBox;
        wc.gInputbox.onkeyup = function()
        {
            //这里调用this.Len()出现运行时错误
            var len = wc.Len();
            alert(len);
        }
    }

解决方案 »

  1.   

    再问下,这样怎么不可以
        function jsTable(gSerchBox,tblName,gHid)
        {
            var wc = this;
            wc.tblName = "aaa";
            wc.gInputbox = gSerchBox;
            wc.gInputbox.onkeyup = wc.kk;
    //        function()
    //        {
    //            var len = wc.Len();
    //            alert(len);
    //        }
        }
        jsTable.prototype.kk = function()
        {
            var len = this.Len();
            alert(len);
        }
        jsTable.prototype.Len = function()
        {
            return 2;
        }    jsTable.prototype.keyup = function()
        {
            var len = this.Len();
            alert(len);
        }我如果要想把onkeyup的方法定义到外面又该如何做呢
      

  2.   

    you do not know that where is the very pointthis.gInputbox.onkeyup = function()
    {
    //这里调用this.Len()出现运行时错误
    var len = this.Len();
    alert(len);
    }
    }at here you call Len using "this". and do you know where "this" point to?in fact, in your code, this.Len() was called by the searchBox, that means:"this" point the searchBox just like the return value of document.getElementById("searchBox")try to do this using another method.if you still have problems, send mail to me: [email protected]
      

  3.   

    function jsTable(gSerchBox,tblName,gHid) {
    var wc = this;
    wc.tblName = "aaa";
    wc.gInputbox = gSerchBox;
    wc.gInputbox.onkeyup = function () {
    wc.kk();
    }
    }
    jsTable.prototype.kk = function() {
    var len = this.Len();
    alert(len);
    }
    jsTable.prototype.Len = function() {
    return 2;
    }jsTable.prototype.keyup = function() {
    var len = this.Len();
    alert(len);
    }
      

  4.   

    是哦,你的代码那地方的this指的是文本输入框
      

  5.   

    除了WC兄弟写的那样,也可以
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>    <script type="text/javascript">
    //定义一个对象
        function jsTable(gSerchBox,tblName,gHid)
        {
            this.tblName = "aaa";
            this.gInputbox = gSerchBox;
            var obj=this
            this.gInputbox.onkeyup = function()
            {
                //这里调用this.Len()出现运行时错误
                var len = this.Len();
                alert(len);
            }
            this.gInputbox.Len=function()
            {
             return 3;
            }
        }
        jsTable.prototype.Len = function()
        {
            return 2;
        }    jsTable.prototype.keyup = function()
        {
            var len = this.Len();//这里调用不会有问题
            alert(len);
        }
       
          
        </script></head>
    <body>
        <form id="form1" runat="server">
            <div>
                <input type="text" id="serchbox" name="serchbox" /><input type=hidden id="hid1" />
                <script type="text/javascript">
              var obj =   new jsTable(document.getElementById("serchbox"),"tName1",document.getElementById("hid1"));
               obj.keyup();
                </script>
            </div>
        </form>
    </body>
    </html>
      

  6.   

    楼上的朋友,我知道你的意思,但是muxrwc(十月,改变) 的方法可以运行,我现在
    想要的是如何把
    wc.gInputbox.onkeyup = function()
    {
    //这里调用this.Len()出现运行时错误
    var len = wc.Len();
    alert(len);
    如何把这个方法分解在调用的时候比如先让wc.gInputbox.onkeyup = "一个方法名";
    jsTable.prototype."一个方法名" = function()
    {
       //在这里调用方法Len,请问该如何实现
    }