使用 JavaScript 清除 Firefox 中的控制台

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25924299/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 05:13:45  来源:igfitidea点击:

Clear the console in Firefox using JavaScript

javascriptfirefox

提问by Michael Schwartz

Is there a way to clear the console in Firefox?

有没有办法清除 Firefox 中的控制台?

In Chrome I can use...

在 Chrome 中,我可以使用...

console.clear()

(Not sure if it works for Safari or Opera though)

(但不确定它是否适用于 Safari 或 Opera)

However I haven't been able to find a solution for Firefox. Is this type of API not yet available? Is there a workaround that doesn't require?

但是,我一直无法为 Firefox 找到解决方案。这种类型的 API 还没有吗?是否有不需要的解决方法?

console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

采纳答案by Todd Mark

In firefox you can just input clear(). It well be done.

在 Firefox 中,您只需输入clear(). 做得很好。

Here's a link to the Developer's website for Javascript console commands: http://msdn.microsoft.com/en-us/library/windows/apps/hh696634.aspx

这是 Javascript 控制台命令的开发人员网站的链接:http: //msdn.microsoft.com/en-us/library/windows/apps/hh696634.aspx

回答by Shayan Ahmad

Keep it simple silly. Better press "Ctrl +Shift +L" to clear the output in Firefox 44+. Whereas in previous versions and in Chrome press "Ctrl + L".

保持简单愚蠢。最好按“Ctrl + Shift +L”清除 Firefox 44+ 中的输出。而在以前的版本和 Chrome 中,按“Ctrl + L”。

回答by Gerard Reches

For anyone who comes to this question, console.clear()works in Firefox since version 48.0.

对于任何遇到此问题的人,console.clear()48.0版起可在 Firefox 中使用。

https://developer.mozilla.org/es/docs/Web/API/Console/clear

https://developer.mozilla.org/es/docs/Web/API/Console/clear

回答by Yusril Maulidan Raji

Perhaps you also want to clear via GUI of the browser.

也许您还想通过浏览器的 GUI 清除。

  1. Open the inspect element / Ctrl+shift+i
  2. click console menu
  3. click the trash bin logo
  1. 打开检查元素/Ctrl+shift+i
  2. 单击控制台菜单
  3. 点击垃圾桶标志

Here is the screenshot:

这是屏幕截图:

enter image description here

在此处输入图片说明

回答by aemonge

I've been looking for future implementations of firefox, but still they don't want to implement it. So basically you can't in webconsole, but you can in firebug.

我一直在寻找 firefox 的未来实现,但他们仍然不想实现它。所以基本上你不能在 webconsole,但你可以在firebug

See: https://developer.mozilla.org/en-US/docs/Web/API/console

请参阅:https: //developer.mozilla.org/en-US/docs/Web/API/console