addEventListener Code Snippet Translation and Usage for cross-browser detectioin
问题 I've come across a piece of code that I'd like to model. However, I just have a few questions and perhaps you guys can help. Here's the code: function addEvent( brw_obj, type, func ) { if (brw_obj.addEventListener) { // all browsers except IE < v9 brw_obj.addEventListener( type, func, false ); } else if (brw_obj.attachEvent) { // IE only for v < v9 brw_obj["e"+type+func] = func; brw_obj[type+func] = function() { brw_obj["e"+type+func]( window.event ); } brw_obj.attachEvent( "on"+type, brw_obj