JavaScript console log in Magento

后端 未结 9 1710
长发绾君心
长发绾君心 2020-12-09 11:46

I have a custom phtml pages in Magento. As far I know Magento uses jQuery and prototype libraries.

For example, if I need external jQuery/jQueryUI, I need t

9条回答
  •  猫巷女王i
    2020-12-09 11:51

    After AlexB post I used this work around.

    var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    
    if (!("console" in window) || !("firebug" in console) && !is_chrome)
    {
        var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
        "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    
        window.console = {};
        for (var i = 0; i < names.length; ++i)
            window.console[names[i]] = function() {}
    }
    

    As you can see, the is_chrome var returns true or false, adding !is_chrome stops the code from running.

提交回复
热议问题