After the Firebug panel is enabled, A Window.console object and a Window.console.firebug variable are added to save the current version of the current Firebug, and when the Firebug panel is turned back to normal, we can detect if the Firebug is turned on by determining whether it exists.
Copy Code code as follows:
Boolean (window.console && window.console.firebug)
Thus, to facilitate the avoidance of scripting errors without enabling Firebug, you can manually create an empty console object to be compatible by adding the following statement at the top of the script.
Copy Code code as follows:
if (!window.console) {
Ignore Firebug console Call if it ' s not installed
For Firebug 1.6.0
(Function (M, i) {
Window.console = {};
while (i--) {
Window.console[m[i]] = function () {};
}
} (' Log debug info warn exception assert dir dirxml trace Group GroupEnd groupcollapsed time Timeend profile Profileend Co UNT Clear Table Error Notifyfirebug '. Split ("), 22);
}
In this way, the normal preview of the page under IE, Firefox, Chrome, Safari can also normal output debugging information.