Use JavaScript to detect whether Firefox browsers enable Firebug code _javascript Tips

Source: Internet
Author: User
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.
Related Article

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.