Login Register

Netscape Fix

I'm required to support Netscape 7.2 and 8.1 for my current project at work, so with that said, this is why I've had to create this patch for Dojo 0.9+. It's probably not the prettiest thing, nor the most optimized, but it's all I have had time for.

If you decide to use this fix, PLEASE READ the comments carefully, as this will not work if you don't place things in the right places.

I've also yet to test this with a Custom Build, so some issues may come up when this point is hit. I'll be updating this shortly when I do finally get to test this in a build. Until then, here you are...

/*
 * netscape_support.js - A browser compatibility module.  Runs before any dojo.require statements.
 *
 *
 *
 * --- ABOUT THIS FIX ---
 *
 * Adds the following support for Netscape:
 *      - Eliminates a 'Too much recursion' issue that gets thrown by dojo.declare._core._findMixin
 *      - New dojo.isNS property, which gets set to the Major version of the browser
 *      - New dj_ns class for dijit (just like dj_ie, dj_ie6, dj_gecko, etc.)
 *      - If you have any questions/suggestions please contact me at strickn@gmail.com
 *
 *
 *
 * --- PLEASE NOTE ---
 *
 * This must be included right after you include the dojo.js (dojo.js.uncompressed.js)
 * files, such that your <script></script> tags go in an order like this...
 *
 * <script type="text/javascript" src="/js/dojo-release-1.1.0/dojo/dojo.js"></script>
 * <script type="text/javascript" src="/js/where_you_want_this_fix/netscape_support.js"></script>
 *
 *
 *
 * --- TODO & Figure Out ---
 *
 *      - Optimize this more if possible
 *      - Should I be removing the dj_gecko class or not?
 *
 */


(function(){
       
        /* First we need to sniff the userAgent string and see if Netscape is even being used. I'm
         * going to borrow the same variable names from dojo/_base/_loader/hosenv_browser to make
         * things similar.
         */

        var n = navigator;
        var dua = n.userAgent;
        var dav = n.appVersion;
       
        /* Get the version number of Netscape and assign our dojo.isNS property. */
        dojo.isNS = dua.indexOf("Netscape") == -1 ? 0 : parseFloat(dav);
       
        /* If Netscape really is being used, then we need to do a few things to make life
         * easier for ourselves down the road.
         */

        if(dojo.isNS){
               
                /* First, we need to re-define the dojo.declare._core._findMixin function, or we're
                 * going to end up in an endless loop, thus throwing a 'Too much recursion' error.
                 */

                dojo.declare._core._findMixin = function(mixin){
                        var c = this.constructor, p, m;
                        while(c){
                                p = c.superclass;
                                m = c.mixin;
                               
                                /* We change the following line to accomodate Netscape. The original line
                                 * is this:
                                 *      if(m==mixin || (m instanceof mixin.constructor)){return p;}
                                 */

                                if(m==mixin || (m && m.constructor === mixin.constructor)){ return p; }
                               
                                if(m && (m=m._findMixin(mixin))){ return m; }
                                c = p && p.constructor;
                        }
                };
               
                /* Now we need to handle the new dj_ns class implementation */
                var html = dojo.doc.documentElement; //TODO browser-specific DOM magic needed?
               
                /* Netscape is going to show up to Dojo as a Gecko-based browser, so we need to
                 * remove this class first, because we're not in FireFox.
                 */

                if(html.className.indexOf("dj_gecko") != -1){
                        html.className = html.className.replace("dj_gecko", "");
                }
               
                /* Now use the same methodology as dijit._base.sniff to add our new dj_ns class */
                if(html.className){
                        html.className += " " + "dj_ns";
                }else{
                        html.className = "dj_ns";
                }
               
        }
       
})();

If anyone needs to support Mozilla 1.7/1.8...

If anyone needs to support Mozilla 1.7/1.8, this fix will probably work, as well.

Right-to-left issues or quirks mode issues

Justin and I had a quick chat about this fix.

Any developers needing to supported languages that use RTL (vs LTR) languages, should disable the code that removes the "dj_gecko" class from the document element (HTML tag). There are a few other minor tweaks (in the Slider and Tab Container widgets) that use the "dj_gecko" class, but these are probably minor.

Anybody using quirks mode (does anybody still use quirks mode :-) ?), may need the "dj_gecko" back in there.