Skip to content

Instantly share code, notes, and snippets.

@bendodson
Created January 23, 2012 12:16
Show Gist options
  • Save bendodson/1662801 to your computer and use it in GitHub Desktop.
Save bendodson/1662801 to your computer and use it in GitHub Desktop.
Basic jQuery plugin to allow console logging in browsers without JavaScript consoles
jQuery.consoleConfig = function(useConsole,useAlert)
{
if (arguments.length == 0) {
var useConsole = true;
var useAlert = true;
} else if (arguments.length == 1) {
var useAlert = true;
}
if (!window.console || !useConsole) {
if (!useConsole) {
delete console;
}
console = new Object;
console.log = function(message) {
if (useAlert) {
alert(message);
}
}
console.info = function(message) {
if (useAlert) {
alert('Info: '+message);
}
}
console.warn = function(message) {
if (useAlert) {
alert('Warning: '+message);
}
}
console.error = function(message) {
if (useAlert) {
alert('Error: '+message);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment