Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.