UPDATE:
It looks like you can now override the console object. I suggest you look at Insin (which was posted as a comment on this answer).
Only Firebug offers a console object for JavaScript.
This fix will prevent JavaScript from breaking in Internet Explorer and other browsers if the Firebug console object is used at design time.
This is a great solution for debugging the same application in multiple browsers. (No longer comments on all your calls to console objects.)
try { var console = { log: function () { return; }, debug: function () { return; }, info: function () { return; }, warn: function () { return; }, error: function () { return; }, "assert": function () { return; }, dir: function () { return; }, dirxml: function () { return; }, trace: function () { return; }, group: function () { return; }, groupEnd: function () { return; }, time: function () { return; }, timeEnd: function () { return; }, profile: function () { return; }, profileEnd: function () { return; }, count: function () { return; } }; } catch (e) { }
You can even change the console object to work in other browsers:
try { var console = { log: function () { for (msg in arguments) { alert(msg); } }, ....
The net bonus is that Visual Studio can now recognize the console object and its methods.
roosteronacid 02 Oct '08 at 10:11
source share