Annotation of 2002/css-validator/tabtastic/attachevent.js, revision 1.1

1.1     ! ot          1: //*** This code is copyright 2003 by Gavin Kistner, gavin@refinery.com
        !             2: //*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
        !             3: //*** Reuse or modification is free provided you abide by the terms of that license.
        !             4: //*** (Including the first two lines above in your source code satisfies the conditions.)
        !             5: 
        !             6: 
        !             7: //***Cross browser attach event function. For 'evt' pass a string value with the leading "on" omitted
        !             8: //***e.g. AttachEvent(window,'load',MyFunctionNameWithoutParenthesis,false);
        !             9: 
        !            10: function AttachEvent(obj,evt,fnc,useCapture){
        !            11:        if (!useCapture) useCapture=false;
        !            12:        if (obj.addEventListener){
        !            13:                obj.addEventListener(evt,fnc,useCapture);
        !            14:                return true;
        !            15:        } else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
        !            16:        else{
        !            17:                MyAttachEvent(obj,evt,fnc);
        !            18:                obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
        !            19:        }
        !            20: } 
        !            21: 
        !            22: //The following are for browsers like NS4 or IE5Mac which don't support either
        !            23: //attachEvent or addEventListener
        !            24: function MyAttachEvent(obj,evt,fnc){
        !            25:        if (!obj.myEvents) obj.myEvents={};
        !            26:        if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
        !            27:        var evts = obj.myEvents[evt];
        !            28:        evts[evts.length]=fnc;
        !            29: }
        !            30: function MyFireEvent(obj,evt){
        !            31:        if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
        !            32:        var evts = obj.myEvents[evt];
        !            33:        for (var i=0,len=evts.length;i<len;i++) evts[i]();
        !            34: }

Webmaster