1
console.log的禁用与恢复
source link: https://xushanxiang.com/disable-restore-console-log.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
console.log的禁用与恢复
作者: xusx
分类: JavaScript
发布时间: 2022-12-06 13:47
浏览:5
禁用console.log
在脚本中重新定义控制台日志函数
var console={};
console.log=function(){}; // 禁用所有控制台输出
恢复console.log
通过将其拉出iframe,在已删除的页面上恢复console.log
function setConsole() {
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
console = iframe.contentWindow.console;
window.console = console;
}
setConsole();
如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK