function action(o,e)        //函数改成这样
{
alert("action");  
}xmlTree.prototype.Displaytree = function(id) //{
    this.html = '<input id="BtnDel" type="button" value="test" onclick="action (this,event);">';             //---------这里的action失效,如何改?
    return this.html;
}

解决方案 »

  1.   

    this.html = '<input id="BtnDel" type="button" value="test" onclick="this.action (this,event);
      

  2.   

    失啥效啊,你把Displaytree 的一大括号给注释掉了
    ----------------------------------------------
    <script language="javascript">
    function xmlTree(name) 
    {
        this.name   = name;   
        this.html   = '';              
    }xmlTree.prototype.createTree = function (obj) //生成树
    {       
     document.write("<div id='tree'><\/div>");
         var curHtml=this.Displaytree();                     
         document.getElementById('tree').innerHTML = curHtml;}xmlTree.prototype.action = function (o,e)        
    {
    alert("action");  
    }xmlTree.prototype.Displaytree = function(id) {
        this.html = '<input id="BtnDel" type="button" value="test" onclick="action (this,event);">';             //---------这里的action失效,如何改?
        return this.html;
    }function action(){
    alert('d');
    }
    </script><head>
        <title>Untitled Page</title>
    </head>
    <body>
        <script>
        var tree = new xmlTree('tree');
        tree.createTree ();
        </script>
    </body>
    </html>
      

  3.   

    function xmlTree(name) 
    {
        this.name   = name;   
        this.html   = '';
        this.xmldom;
    }
    xmlTree.prototype.action = function (o,e)        

        cols = this.xmldom.parentNode.getElementsByTagName("ul");
        ***
    }xmlTree.prototype.createTree = function (obj) {    
         this.xmldom =  new ActiveXObject("Microsoft.XMLDOM");
         this.xmldom.async = false;
         this.xmldom.load(this.xmlFile);
         var curHtml=this.Displaytree();
         document.write("<div id='tree'><\/div>");                     
         document.getElementById('tree').innerHTML = curHtml;
    }action = function (o,e)        
    {
      alert(this.xmldom.parentNode.getElementsByTagName("ul"));     
     //-!!报错"this.xmldom.parentNode" is null or not an object
      cols = this.xmldom.parentNode.getElementsByTagName("ul");  
    }xmlTree.prototype.Displaytree = function(id) //{
        this.html = '<input id="BtnDel" type="button" value="test" onclick="action (this,event);">';             
        return this.html;
    }
      

  4.   

    晕死
    this.xmldom就是这个XML啊