用microsoftAjax.js框架来进行事件监听

<html> 
  <head> 
    <script src="MicrosoftAjax.js" type="text/javascript"></script>
  </head>

 

 


  
  <body>


          <div  id="layer1" style="background-color:red">
          <div   name="layer2"> <input   type=button   value="关闭第2层" >  </div> 
          <div  name="layer3"> <input    type=button   value="关闭第3层">  </div> 
          </div>           
  
        
        
 <script type="text/javascript">

    Type.registerNamespace("find");

    find.layers=function(layers)
       {
     this._layers=layers;
   
    this._clickDelegate = Function.createDelegate(this, this.alert);
       };


    find.layers.prototype = {

  initialize : function()
                           {       alert(this._layers);
                                find.layers.callBaseMethod(this, "initialize");
     
                                $addHandler( this._layers, "click",this._clickDelegate);
                           },
      
          alert    : function()
                 { alert("i am layer2");}
    };


     find.layers.registerClass("find.layers", Sys.Component);
alert(document.getElementById('layer1'));
   var layer=new find.layers($get('layer1'));

     layer.initialize();


  
</script>
  </body> 
  </html>

posted @ 2009-07-20 19:40  依然神思者  阅读(285)  评论(0编辑  收藏  举报