Restoring console.log()

后端 未结 8 2402
粉色の甜心
粉色の甜心 2020-11-29 22:25

For some reason, the prototype framework (or another JavaScript code) that is shipped with Magento is replacing standard console functions, so I can\'t debug anything. Writi

8条回答
  •  既然无缘
    2020-11-29 23:00

    Save a reference to the original console in a variable at the very start of the script and then either use this reference, or redefine console to point to the captured value.

    Example:

    var c = window.console;
    
    window.console = {
        log :function(str) {
            alert(str);
        }
    }
    
    // alerts hello
    console.log("hello");
    
    // logs to the console
    c.log("hello");
    

提交回复
热议问题