MCPcopy Create free account
hub / github.com/unconed/TermKit / attachEvent

Function attachEvent

HTML/external/syntaxhighlighter_3.0.83/src/shCore.js:615–641  ·  view source on GitHub ↗

* Adds event handler to the target object. * @param {Object} obj Target object. * @param {String} type Name of the event. * @param {Function} func Handling function.

(obj, type, func, scope)

Source from the content-addressed store, hash-verified

613 * @param {Function} func Handling function.
614 */
615function attachEvent(obj, type, func, scope)
616{
617 function handler(e)
618 {
619 e = e || window.event;
620
621 if (!e.target)
622 {
623 e.target = e.srcElement;
624 e.preventDefault = function()
625 {
626 this.returnValue = false;
627 };
628 }
629
630 func.call(scope || window, e);
631 };
632
633 if (obj.attachEvent)
634 {
635 obj.attachEvent('on' + type, handler);
636 }
637 else
638 {
639 obj.addEventListener(type, handler, false);
640 }
641};
642
643/**
644 * Displays an alert.

Callers 2

shCore.jsFile · 0.85
quickCodeHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected