Skip to main content

A cross-browser logging function. Will attempt to use the developer console (i.e.: FireBug) first, and fallback to using alert() when not detected.

function log() {
  try {
    console.log.apply(console, arguments);
  } catch (e) {
    try {
      opera.postError.apply(opera, arguments);
    } catch (e) {
      alert(Array.prototype.join.call(arguments, " "));
    }
  }
}

// Example
log("here's my log message");