function netgyPopUp(targetURL){
this.targetURL = targetURL;
this.open = function (){
var i=window.open("about:blank","_backad","width=750,height=480,toolbar=no,location=no,directories=no,status=yes,resizable=no,scrollbars=no");
i.blur();
i.opener.focus();
//i.location=targetURL;这样可以
i.location=this.targetURL;//为什么这样就不行
}
}
var netgyPopWIn = new netgyPopUp('http://www.ifeng.com');
  (function (){
try{
netgyPopWIn.open();
}catch(e){
document.onclick=netgyPopWIn.open;
}finally{

}
  })();
见代码内注释,这是什么

解决方案 »

  1.   


     this.open = function (){
                            var i=window.open("about:blank","_backad","width=750,height=480,toolbar=no,location=no,directories=no,status=yes,resizable=no,scrollbars=no");
                            i.blur();
                            i.opener.focus();
                            //i.location=targetURL;这样可以
                            i.location=this.targetURL;//因为这里的this指向的是你的open的event对象,等于event.srcElement,两个this所指不同
                        }
      

  2.   

        不知道我这样讲对不对:就是this用以指代一个对象自身或者是变量自身,它的作用是将自己当成对象。然而是不是与这条语句(this.targetURL = targetURL或者this.x = x)有矛盾呢?