{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
AJAX Source Viewer
View the source code of a Method from ASP.NET AJAX Library. Choose a method from the menu items above (Namespaces, Classes, or Methods).
Method 'addHandler(element, eventName, handler)'
Method: addHandler(element, eventName, handler)
Method Full Name:     Sys$UI$DomEvent$addHandler(element, eventName, handler)
Class: DomEvent
Namespace: Sys.UI
Source File: MicrosoftAjax.debug.js
1   var $addHandler = Sys.UI.DomEvent.addHandler = function Sys$UI$DomEvent$addHandler(element, eventName, handler) {
2     /// <summary locid="M:J#Sys.UI.DomEvent.addHandler" />
3     /// <param name="element"></param>
4     /// <param name="eventName" type="String"></param>
5     /// <param name="handler" type="Function"></param>
6     var e = Function._validateParams(arguments, [
7     {name: "element"},
8     {name: "eventName", type: String},
9     {name: "handler", type: Function}
10    ]);
11    if (e) throw e;
12    Sys.UI.DomEvent._ensureDomNode(element);
13    if (eventName === "error") throw Error.invalidOperation(Sys.Res.addHandlerCantBeUsedForError);
14    if (!element._events) {
15      element._events = {};
16    }
17    var eventCache = element._events[eventName];
18    if (!eventCache) {
19      element._events[eventName] = eventCache = [];
20    }
21    var browserHandler;
22    if (element.addEventListener) {
23      browserHandler = function(e) {
24        return handler.call(element, new Sys.UI.DomEvent(e));
25      }
26      element.addEventListener(eventName, browserHandler, false);
27    }
28    else if (element.attachEvent) {
29      browserHandler = function() {
30        var e = {};
31        try {e = Sys.UI.DomElement._getWindow(element).event} catch(ex) {}
32        return handler.call(element, new Sys.UI.DomEvent(e));
33      }
34      element.attachEvent('on' + eventName, browserHandler);
35    }
36    eventCache[eventCache.length] = {handler: handler, browserHandler: browserHandler};
37  }
This is the JavaScript source for method addHandler(element, eventName, handler) from ASP.NET AJAX Library. Full name for this method is Sys$UI$DomEvent$addHandler(element, eventName, handler). It belongs to the class DomEvent, which is in Sys.UI namespace. This source is in MicrosoftAjax.debug.js file.
Bookmark and Share This
About  Contact  Privacy Policy  Site Map