When Firebug is enabled, access to GMail will receive a warning that Firebug will slow down Gmail. How can this be detected? Let's talk about it here. After the firebug panel is enabled, a window is added. console object and window. console. the firebug variable is used to save the current version of the current firebug. When the firebug panel is closed, the variable returns to normal. Therefore, we can check whether the firebug is enabled by checking whether it exists.
The Code is as follows:
Boolean (window. console & window. console. firebug)
Therefore, to avoid script errors without enabling firebug, you can add the following statement at the beginning of the script to manually create an empty console object for compatibility.
The Code is 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 count clear table error policyfirebug '. split (''), 22 );
}
In this way, the page can be normally previewed in IE, and debugging information can be normally output in Firefox, Chrome, and Safari.