How we can clear the Console in Chrome, Firefox and other browsers. I've tried the following commands, but none is working:
Chrome: clear()
Firefox: console.clear()
Any ideas?
Use the short cut Ctrl + L to clear the console. Use the clear log button on the top left corner of the chrome dev tools console to clear the console. On MacOS you can use Command + K button.
clear() The console. clear() method clears the console if the console allows it.
CTRL + L as Shortcut to clear Developer Console.
For every browser it is different so you can write some script so that it will work for different browsers. or you can use this script
console.API;
if (typeof console._commandLineAPI !== 'undefined') {
console.API = console._commandLineAPI; //chrome
} else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
console.API = console._inspectorCommandLineAPI; //Safari
} else if (typeof console.clear !== 'undefined') {
console.API = console;
}
console.API.clear();
so on for other browsers too.
Note: Successfully tested (after edit, 08/2016) in Safari v9.1 for Mac OS, and Chrome v52.0 for Mac OS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With