简体   繁体   中英

Chrome “delete console” - how to restore it?

It's possible to restore chrome console after: delete console

Google Chrome version: 46.0.2490.80 m

In previous versions this command restore original console, but now I receive message:

Uncaught ReferenceError: console is not defined

Well, it's easy and it's already been asked:

function healConsole() {
  //<iframe> element
  var iframe = document.createElement("iframe");
  //Hide it somewhere
  iframe.style.position="fixed";
  iframe.style.height = iframe.style.width = "1px";
  iframe.style.top = iframe.style.left = "-5px";
  //No src to prevent loading some data
  iframe.src = "about: blank";
  //Needs append to work
  document.body.appendChild(iframe);
  //Get the inner console
  window.console = iframe.contentWindow.console;
}

Originally asked here: Get access to the console once the console object reference was changed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM