Use JavaScript to check if Firebug code is enabled in Firefox

Source: Internet
Author: User

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. Copy codeThe 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.Copy codeThe 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.