Fixed #85 using attachEvent in older browsers