Restoring console.log()

后端 未结 8 2393
粉色の甜心
粉色の甜心 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 22:52

    Just in case that someone face this same situation. I did not replied to the original answer for Xaerxess because I don't have enough reputation to do it. Looks like that is the correct answer, but for some reason I notice sometimes it works in my software and sometimes not...

    So I tried completing deleting before running the script and looks like everything is working fine 100% of times.

    if (!("console" in window) || !("firebug" in console))
    {
    
      console.log = null;
      console.log;         // null
    
      delete console.log;
    
      // Original by Xaerxess
      var i = document.createElement('iframe');
      i.style.display = 'none';
      document.body.appendChild(i);
      window.console = i.contentWindow.console;
    
    }

    Thank you to everybody.

提交回复
热议问题