Revision: 58823
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 3, 2012 18:39 by timsommer
Initial Code
var addMyEvent = function( el,ev,fn ){ if(el.addEventListener){ el.addEventListener( ev,fn, false ); }else if(el.attachEvent){ el.attachEvent( 'on'+ ev, fn ); } else{ el['on' + ev] = fn; } };
Initial URL
Initial Description
When we put up a facade, we present an outward appearance to the world which may conceal a very different reality. This was the inspiration for the name behind the facade pattern. The facade pattern provides a convenient higher-level interface to a larger body of code, hiding its true underlying complexity. Think of it as simplifying the API being presented to other developers, something which almost always improves usability. This is an unoptimized code example, but here we're utilizing a facade to simplify an interface for listening to events cross-browser. We do this by creating a common method that can be used in one’s code which does the task of checking for the existence of features so that it can provide a safe and cross-browser compatible solution.
Initial Title
JavaScript Facade
Initial Tags
javascript
Initial Language
JavaScript