感觉太灵活,不知道能有什么办法能准确识别this指向的是哪个对象?

解决方案 »

  1.   

    alert(this);
    function()
    {
    var me=this;
    alert(me);
    this.name=function(){alert(me)}
    }
      

  2.   

    我是个菜鸟,不是很懂楼上的代码的含义,bhtfg538 能否解释一下!谢谢!
      

  3.   

    this 一般指的是当前的对象。也就是你当前所操作的对象,方法...
      

  4.   

    关键字this总是指向调用该方法的对象.
    可以用alert(this.tostring())或者alert(this.valueof())测试调用的对象的名字
      

  5.   

    <marquee direction="up" onmousemove="this.stop()" onmouseout="this.start()" scrollamount="1">淡淡的</marquee>
    这是一个滚动的文字  这里的this==当你用鼠标移动到(淡淡的)这个东东  
      

  6.   

    var self = this;
    timer=windows.setInterval(self.drop.bind(self),50);
    和以下代码的this是同样的吗?
    timer=windows.setInterval(this.drop.bind(this),50);
      

  7.   

    <input id="btn1" type="button" value="Button1" onclick="javascript:alert(this.id);" /> 
    <script language="javascript" type="text/javascript"> 
    function fun(){ 
    this.open("*.aspx", "null", ""); 

    </script> 
    <input id="btn2" type="button" value="Button2" onclick="javascript:fun();" /> 第一个this指的是按钮btn1对象 
    第二个this指的是窗体window对象
      

  8.   

    var self = this; 
    timer=windows.setInterval(self.drop.bind(self),50); 
    和以下代码的this是同样的吗? 
    timer=windows.setInterval(this.drop.bind(this),50);