Microsoft Ajax library cheat sheet (4): domevent class

Source: Internet
Author: User

The original cheat sheet (PDF version) is here to download: http://aspnetresources.com/downloads/ms_ajax_library_cheat_sheets1.zip

Original copyright statement:

Copyright (c) 2004-2006, Milan negovan http://www.AspNetResources.comAll rights reserved. redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * redistributions of source code must retain the above copyright notice, this list of conditions and the following disclawing. * redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclawing in the documentation and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. this software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited, the implied warranties of merchantability and fitness for a special purpose are disclaimed. in no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

 

NOTE: If [s] is marked as a static method, it can be used without instantiating an object.

 

[S] addhandler (element, eventname, Handler)
[S]$ Addhandler (element, eventname, Handler)

Add the processing function of an event to the DOM element. The "on" prefix should be removed from the event name.

Note: In the event processing function, this points to the element, not necessarily the element that sends the event.

 
SYS. UI. domevent. addhandler (element,"Click", Clickhandler );
 
// Same as $ addhandler (element, "click", clickhandler );
 
FunctionClickhandler (e ){... }

 

[S]Addhandlers (element, events, handlerowner)
[S]$ Addhandlers (element, events, handlerowner)

Add multiple event processing functions to the DOM element. events is the dictionary of an event processing function.

NOTE: If handlerowner is specified in the event processing function, this points to the handlerowner. Otherwise, this points to the element.

 
$ Addhandlers ($ get ("Article"),{
 
Mouseover: onmouseover,
 
Mouseout: onmouseout
 
});
 
FunctionOnmouseover (e ){This. Style. backgroundcolor ='Yellow';}
 
FunctionOnmouseout (e ){This. Style. backgroundcolor ='White';}

 

[S]Clearhandlers (element)
[S]$ Clearhandlers (element)

Removes all event handlers from the specified Dom element.

 
SYS. UI. domevent. clearhandlers (element );
// Same as $ clearhandlers (element );

 

[S]Removehandler (element, eventname, Handler)
[S]$ Removehandler (element, eventname, Handler)

Removes the specified event handler for the DOM element.

 
SYS. UI. domevent. removehandler (element,"Click", Clickhandler );
 
// Same as $ removehandler (element, "click", clickhandler );

 

Preventdefault ()

Blocks the execution of default event processing functions. For example, if the onclick event of Element A is blocked, page navigation is not triggered.

 
$ Addhandler ($ get ("Showmorelink"),"Click", Showmore );
 
FunctionShowmore (e) {e. preventdefault ();}

 

Stoppropagation ()

Prevents event bubbles from being passed to the parent element.

 

Attribute of event object

    1. altkey : determines whether the Alt key is pressed when the event is triggered.
    2. button : click the mouse that triggers the event. Optional values: SYS. UI. mousebutton enumeration (leftbutton, middlebutton, and rightbutton ).
    3. charcode : Enter the Code button on the keyboard when the event is triggered. You can enumerate SYS. UI. Key (backspace, tab, enter, ESC, space, Pageup, Pagedown, end, home, left, up, right, down, del ).
    4. clientx : X coordinate of the mouse pointer relative to the visible area of the document.
    5. clienty : Y coordinate of the mouse pointer relative to the visible area of the document.
    6. ctrlkey : determines whether the ctrl key is pressed when the event is triggered.
    7. offsetx : the offset of the mouse pointer to the left edge of the trigger event element.
    8. offsety : the offset of the cursor to the edge of the trigger event element.
    9. rawevent : the original DOM event.
    10. screenx : The X coordinate of the mouse pointer relative to the viewer's screen.
    11. screeny : Y coordinate of the mouse pointer relative to the viewer's screen.
    12. shiftkey : determines whether the Shift key is pressed when the event is triggered.
    13. Target : the object that triggers the event.
    14. type : event name (for example, click ").
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.