function testObj(name){    -->   function testObj(){var test1=new testObj();
test1.name="test1name";
test1.show();
var test2=new testObj();
test2.name="test2name";
test2.show();

解决方案 »

  1.   

    function testObj(name){
    this.name=name;
    this.show=function(){
    alert(this.name.match(/^test\d+/i));
    }
    }var test1=new testObj("test1name");
    test1.show();
    var test2=new testObj("test2name");
    test2.show();还是不大清楚你想干什么 试试这个
      

  2.   

    原本的意图是这样的
    function createDiv(id){
    this.id=id;
    this.method=function(){};
    }
    建立一个对象层
    然后写对象层中的innerHTML,中间有一句
    <a href="javascript:void(0);onclick=xxxxxx;">调用对象层的method方法</a>
    由于种种原因,不能使用
    a=creatElement("A")
    a.onclick=function(){
    this.method();
    }
    这样的形式,
    现在是用
    var test=new createDiv("test")<a href="javascript:void(0);onclick=eval(" + this.id + ").method();">调用对象层的method方法</a>的变通方法解决的
      

  3.   

    <a href="javascript:void(0);onclick=new_function(this)">调用对象层的method方法</a>function new_function(o){
    eval(o.id).method();
    }
      

  4.   

    帮LZ顶
      
    http://user.qzone.qq.com/31767702
      

  5.   

    ttyp的方法貌似更不对,这样往new_function中传递的this对象就变成了<a>自己,执行就成了
    eval(a的id).method()
      

  6.   

    难道真的要用eval?
    变通一下,再等一天
      

  7.   

    eval(a.parentNode.id).method()反正你找找他们之间的关系就是了