当前位置:网站首页>【黄啊码】我用这个方式清理了谷歌浏览器的控制台
【黄啊码】我用这个方式清理了谷歌浏览器的控制台
2022-06-10 10:49:00 【黄啊码】
我想知道如果我能用一些命令清理控制台..
console.log() ,可以打印…有清除控制台的命令?..
我试图console.log(console); 并在下面得到这个function…
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 [我想没有办法清理控制台…但我想要有人对我说…]
如果你inputclear()到控制台,清除它。
我不认为有办法编程,因为它可能会被滥用。 (控制台被某个网页清除,最终用户不能访问错误信息)
一个可能的解决方法:
在控制台中键入window.clear = clear ,那么你可以在页面上的任何脚本中使用clear。
总有一个很好的技巧:
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"); 不是最优雅的解决scheme,我知道:)但是工作。
对我而言,我通常只是打印一个长的“—–”分隔线,以便日志更容易阅读。
如果您使用console.clear() ,似乎在铬中工作。 请注意,它会输出一个“控制台被清除”的信息。
我测试了这个通过收集了大量的JavaScript错误。
请注意,清除控制台后,我得到一个错误,所以它不会禁用控制台,只清除它。 另外,我只在Chrome中试过,所以我不知道它是如何跨浏览器。
编辑: 我在Chrome,IE,Firefox和Opera中testing了这个。 它可以在Chrome,MSIE和Opera的默认控制台中使用,但不能在Firefox中使用,但是它可以在Firebug中使用。
这似乎工作得很好:
console.clear(); console._commandLineAPI.clear(); 苹果浏览器:
console._inspectorCommandLineAPI.clear(); 你可以创build你自己的variables,它可以在
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() 。
如果您想在debugging时清除控制台,只需点击“禁止”button即可清除console.log。
或者只需按下 “Ctrl + L” 使用键盘清除控制台。
PressCTRL+L快捷键清除log ,即使您勾选Preserve log选项。 希望这可以帮助。
在Mac上,您也可以像在terminal中一样使用⌘+K
console._inspectorCommandLineAPI.clear() 这是工作
在Chrome控制台上用鼠标右键单击,我们可以select清除控制台
在Chrome中进行本地debugging时,我使用以下命令来cls (在控制台中input以下JavaScript):
Object.defineProperty(window, 'cls', { get: function () { return console.clear(); } }); 现在在控制台中inputcls将清除控制台。
基于Cobbal的回答 ,这是我所做的:
在我的JavaScript我把以下内容:
setInterval(function() { if(window.clear) { window.clear(); console.log("this is highly repeated code"); } }, 10); 条件代码将不运行,直到你ASSIGN window.clear(意味着你的日志是空的,直到你这样做)。 在debugging控制台中:
window.clear = clear; 清理自己的日志。
Chrome – 按住CTRL + L,同时调整控制台input。
Firefox – clear()在控制台input。
Internet Explorer – 按住CTRL + L,同时调整控制台input。
边缘 – 在对焦控制台input的同时按CTRL + L。
祝你有美好的一天!
您可以使用
console.clear(); 如果你正在使用JavaScript编码。
否则你可以使用CTR+L来清除cosole编辑器。
不要input命令,只需按下:
CLTRL + L 清除Chrome控制台
由于“安全问题”,我认为这是不可用的。
console.log(console)从代码给出:
Console memory: MemoryInfo profiles: Array[0] __proto__: Console 从代码之外,_commandLineAPI可用。 有点烦,因为有时我只想logging而不看旧的输出。
用编程方式清除控制台的多个答案的方便编译(从脚本, 而不是控制台本身):
if(console._commandLineAPI && console._commandLineAPI.clear){ console._commandLineAPI.clear();//clear in some safari versions }else if(console._inspectorCommandLineAPI && console._inspectorCommandLineAPI.clear){ console._inspectorCommandLineAPI.clear();//clear in some chrome versions }else if(console.clear){ console.clear();//clear in other chrome versions (maybe more browsers?) }else{ console.log(Array(100).join("\n"));//print 100 newlines if nothing else works } 我要补充一点,因为这是一个search,出现在谷歌顶部..
当使用ExtJS / Javascript我插入这个和控制台被清除 – 除非有错误..
console.log('\033[2J'); 我很可能偏离过程,但这是我清除每个页面加载/刷新的控制台。
边栏推荐
- 杰理之BLE timer 时钟源不能选 OSC 晶振【篇】
- 隐式转换导致的cpu负载近100%
- Academic lecture: masp for multi label active learning
- [time series prediction] esrnn paper reading
- Golang cli framework --cobra
- 更耐用的遊戲真無線耳機,電池超大續航持久,英雄G1上手
- Hardcore spoiler! With 11 topics and 14 celebrities, dragon dragon dragon community entered Intel meetup and announced the agenda!
- 【通信协议】UART,I2C,SPI复习
- Development of NFT chain game gamefi system and construction of meta universe games
- MySQL practice 45 lectures_ 8_ Deepen the understanding of MySQL repeatable reading from a problem
猜你喜欢

中台:数据中台、业务中台、技术中台、应用中台、AI中台……

Development of NFT chain game gamefi system and construction of meta universe games

硬核剧透!11个议题、14位大咖,龙蜥社区走进 Intel MeetUp 议程公布!

在线文档协作工具,是提高工作效率的第一步

基于分层自监督学习将视觉Transformer扩展到千兆像素图像

Efficiency tools: utools

Leetcode 1991. Find the middle position of the array (brute force enumeration)

Northrop Grumman has passed the registration: the annual revenue is 600million, and Wu Jie, the actual controller, is an American

How to choose cities, schools and majors for the college entrance examination?

子网划分不会?瑞哥带你深入理解IP地址,手把手教你子网划分!
随机推荐
PV操作每日一题-独木桥问题(变式一)
[time series prediction] esrnn paper reading
切换npm的淘宝镜像
【C语言】#pragma pack(1) 和#pragma pack()
PV操作每日一题-独木桥问题
MySQL architecture
单片机触发器或非门工作原理以及用途
企评家分不同维度解析:湖南长城科技信息有限公司企业成长性
Golang cli framework --cobra
在线文档协作工具,是提高工作效率的第一步
PV操作每日一题-售票问题
数商云通讯行业数字化供应链协同系统:赋能通讯企业改善供应业务,增强市场竞争力
基于分层自监督学习将视觉Transformer扩展到千兆像素图像
杰理之BLE功耗异常【篇】
可以在网上炒股开户吗?是安全的吗?
PV操作每日一题-黑白棋子问题
PV操作每日一题-考试问题
AttributeError: module ‘gym.envs.box2d‘ has no attribute ‘LunarLander‘ 解决办法
效率工具 : uTools
rt-thread 使用宝典(2022-0516更新)