我想知道我是否可以清除控制台的一些命令。
Console.log(),可以打印…是否有清除控制台的命令?
我已经尝试console.log(控制台);得到下面这个函数。
assert: function assert() { [native code] }
constructor: function Console() { [native code] }
count: function count() { [native code] }
debug: function debug() { [native code] }
dir: function dir() { [native code] }
dirxml: function dirxml() { [native code] }
error: function error() { [native code] }
group: function group() { [native code] }
groupEnd: function groupEnd() { [native code] }
info: function info() { [native code] }
log: function log() { [native code] }
markTimeline: function markTimeline() { [native code] }
profile: function profile() { [native code] }
profileEnd: function profileEnd() { [native code] }
time: function time() { [native code] }
timeEnd: function timeEnd() { [native code] }
trace: function trace() { [native code] }
warn: function warn() { [native code] }
__proto__: Object
我想没有办法清理控制台……但我希望有人对我说……]
在MacOS:
Chrome - CMD+K
Safari - CMD+K
Firefox -没有快捷方式
在Linux上:
Chrome - CTRL+L
Firefox -没有快捷方式
在Windows上:
Chrome - CTRL+L
Ie - ctrl + l
边- CTRL+L
Firefox -没有快捷方式
为了让它在Firefox中工作,可以使用用户脚本。下载FF的GreaseMonkey扩展。
document.addEventListener("keydown",function(event){
if(event.metaKey && event.which==75) //CMD+K
{
console.clear();
}
});
在脚本中,用值//@include *://*/*更新元数据,使其在每个页面上运行。只有当焦点在页面上时,它才会工作。这只是个变通办法。
铬:
console._commandLineAPI.clear();
Safari:
console._inspectorCommandLineAPI.clear();
你可以创建自己的变量,它可以在以下两种情况下工作:
if (typeof console._commandLineAPI !== 'undefined') {
console.API = console._commandLineAPI;
} else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
console.API = console._inspectorCommandLineAPI;
} else if (typeof console.clear !== 'undefined') {
console.API = console;
}
在此之后,您可以简单地使用console.API.clear()。
在MacOS:
Chrome - CMD+K
Safari - CMD+K
Firefox -没有快捷方式
在Linux上:
Chrome - CTRL+L
Firefox -没有快捷方式
在Windows上:
Chrome - CTRL+L
Ie - ctrl + l
边- CTRL+L
Firefox -没有快捷方式
为了让它在Firefox中工作,可以使用用户脚本。下载FF的GreaseMonkey扩展。
document.addEventListener("keydown",function(event){
if(event.metaKey && event.which==75) //CMD+K
{
console.clear();
}
});
在脚本中,用值//@include *://*/*更新元数据,使其在每个页面上运行。只有当焦点在页面上时,它才会工作。这只是个变通办法。