...without removing the calls to console.log
obviously. It doesn't need to log or do anything, I just want it to not show an error. I'm trying
if (!window.console) {
window.console = {
log: function() {},
error: function() {},
warn: function() {}
}
}
But that doesn'开发者_开发问答t seem to fix it.
Use debug.log with the following js file instead. It kicks ass.
http://benalman.com/projects/javascript-debug-console-log/
Just taking a wild guess, but
if (typeof window.console !== "undefined") { ... }
would probably solve your issue.
window.console = window.console || {log: function() {}};
I'm using
function trace(s) {
try {
console.log(s);
} catch (e) {
//alert(s);
}
};
trace(foo);
Uncomment the alert if you want to get it in IE.
(I got it from another thread here in SO but i don't remember what was)
精彩评论