Testing if current browser is IE
This technique can work but has a major drawback. The developer must know every browser, every versions and how the features are handled in each of them. You can visit the website http://caniuse.com to check the support of a specific feature in a specific version of a browser .
Instead of implmenting main and fallback solutions for each browser and each browser version, another more reliable approach is to detect the proper handling of a specific feature before making use of it.
Testing the event subscribing method
A good technique is to implement a set of functions that will encapsulate the feature detection. Some cross-browser libraries such as JQuery could also be used.
Custom cross-browser subscribeToEvent()
Use JQuery library
For HTML5/CSS3, we can use the library Modernizr (http://modernizr.com) which purpose is to detect the support of a specific feature in the current browser.
A sample of feature detection with Modernizr
I hope this post will encourage you to make cross-browsers solutions more efficiently by detecting features and you enjoyed reading it.