Salient Solutions

wrasslin ones and nones for fun and profit - Sky Sanders' Blog
Get your own ranked flair here
posts - 92, comments - 108, trackbacks - 0

Saturday, July 10, 2010

JavaScript console and Firebug mocks

For when you don't want to gut your debugging code for IE.

Mock Console
Just enough to swallow 'console.log()' 

        if ("undefined" === typeof window.console)
        {
            window.console = {
                "log": function() { }
            };
        };

Mock Firebug
Fairly complete mock of Firebug.

        if (!("undefined" !== typeof window.console && (window.console.firebugVersion || window.console.firebug )))
        {
            window.console = {
                "assert": function() { },
                "count": function() { },
                "clear": function() { },
                "debug": function() { },
                "dir": function() { },
                "dirxml": function() { },
                "info": function() { },
                "error": function() { },
                "getFirebugElement": function() { },
                "group": function() { },
                "groupEnd": function() { },
                "groupCollapsed": function() { },
                "log": function() { },
                "notifyFirebug": function() { },
                "profile": function() { },
                "profileEnd": function() { },
                "time": function() { },
                "timeEnd": function() { },
                "trace": function() { },
                "warn": function() { },
                "userObjects": [],
                "element": {},
                "firebug": "foo"
            };
        };

posted @ Saturday, July 10, 2010 10:00 PM | Feedback (0) |

Powered by: