Marino
Marino

Reputation: 56

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

Upvotes: 3

Views: 1125

Answers (1)

Tomáš Zato
Tomáš Zato

Reputation: 53190

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

Upvotes: 1

Related Questions