/** * @param action 'on', 'off' or Event type (i.e. 'click') * @param type Event type (i.e. 'click') or DOM Element or other EventTarget * @param target DOM Element to add/remove the event * @param callback Function to add/remove to the target */ function (action, type, target, callback, method, ison) { ison = action == 'on'; method = ison ? 'addEventListener' : 'removeEventListener'; try { target[method](type, callback, false); } catch (e) { try { method = ison ? 'attachEvent' : 'detachEvent'; target[method]('on' + type, callback); } catch (e) { target = document; if (target.createEvent) { target = new Event(action); type.dispatchEvent(target); } else { target = target.createEventObject(); type.fireEvent('on' + action, target); } } } };