I wrote a quick and dirty logger as a jQuery plugin…
(function($){
$.log = function(debug) {
if (console.debug) {
console.debug(debug);
};
};
})(jQuery);
It works fine in Firefox, but in IE7, I’m getting the error…
console.debug is null or not an object
How do I perform a function exists in JavaScript that’s compatible with IE7?
console.debugis specific to Firebug, which runs under Firefox.You need to check if
window.consoleis available before checking forconsole.log!Here’s your code reworked with no errors: