function fn1() { alert(1) } function fn2() { alert(this) } function blind(obj,evname,fn) { if(obj.attachEvent) { obj.attachEvent('on'+evname,function() { fn.call(obj); } ); } else { obj.addEventListener(evname,fn,false); } }; blind(document,'click',fn1);