Created
January 23, 2012 12:16
-
-
Save bendodson/1662801 to your computer and use it in GitHub Desktop.
Basic jQuery plugin to allow console logging in browsers without JavaScript consoles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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