Im trying to add a cross browser event listener to an element so i made my own function that detects weather the browser is IE or Firefox, then add the appropriate eventListener function to the element.

Code JavaScript:
		// CROSS-BROWSER ADD EVENT HELPER METHODS
 
		function addCrossBrowserEventListener (elementName, eventName, functionName) {
			// does the addEventListener function exist?
			if(elementName.addEventListener) {
				// yes - use it
				elementName.addEventListener(eventName, functionName, false);
				return true;
			} else {
				// otherwise use attachEvent for IE
				elementName.attachEvent("on" + eventName, functionName);
				return true;
			}
		}
 
		var name = document.getElementById("name");
 
		function nameLabel () {
			name.innerHTML = "Welcome";
		}
 
		name.addCrossBrowserEventListener(name,"click", nameLabel);

but when i run the code inside Firefox i get a error message "name.addCrossBrowserEventListener is not a function".

So I'm wondering is it possible to add custom functions to elements directly or is there any special way of doing it.