Skip to content

Instantly share code, notes, and snippets.

@jasonwyatt
Created December 16, 2009 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonwyatt/258352 to your computer and use it in GitHub Desktop.
Save jasonwyatt/258352 to your computer and use it in GitHub Desktop.
Tiny javascript snippet/file to overwrite how alert usually works by forcing it to behave like console.log when possible.
/**
* Overwrites the old alert method and chooses to use console.log instead (if it's
* available).
* Author: Jason Feinstein
*/
var oldAlert = alert;
alert = function(){
if(window.console != null){
console.log.apply(null, arguments);
} else {
oldAlert.apply(null, arguments);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment