Javascript Firefox Web 控制台已禁用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8212373/
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
Firefox Web Console Disabled?
提问by yeeen
How come I get this message from Firefox Web Console
我怎么会从 Firefox Web 控制台收到这条消息
The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page
Web 控制台日志记录 API(console.log、console.info、console.warn、console.error)已被此页面上的脚本禁用
The same webpage can print messages in Chrome Console but not Firefox. I opened the same webpage in another computers' Firefox (don't know what version) Web Console can print messages. My Firefox version is the latest, 8.0.
同一个网页可以在 Chrome 控制台中打印消息,但不能在 Firefox 中打印。我在另一台电脑的Firefox(不知道是什么版本)Web Console 中打开了相同的网页,可以打印消息。我的 Firefox 版本是最新的,8.0。
回答by Boris Zbarsky
This happens when the page itself defines a global variable called console
, for example. If the page is browser-sniffing to decide whether to define it, the behavior could differ in different browsers.
例如,当页面本身定义了一个名为 的全局变量时,就会发生这种情况console
。如果页面是浏览器嗅探来决定是否定义它,则行为在不同的浏览器中可能会有所不同。
In the case of Firefox it also happens when Firebug is installed and its console is enabled, since that overrides the default window.console
.
在 Firefox 的情况下,它也会在安装 Firebug 并启用其控制台时发生,因为这会覆盖默认的window.console
.
回答by Costa
I had the same exact error message, and once I removed firebug, it went away.
我有完全相同的错误消息,一旦我删除了萤火虫,它就消失了。
I'm not saying you should remove firebug, I love firebug, but that is most probably the source of the error for you as well. One more note, the error was still there even if firebug was turned off (disabled) for that particular page.
我并不是说你应该删除 firebug,我喜欢 firebug,但这很可能也是你错误的根源。还要注意的是,即使该特定页面的 firebug 已关闭(禁用),错误仍然存在。
回答by dominik
Here is a JavaScript workaround I used to restore console API after it was set to empty function by a script on the page (works in Firefox 46, tested in Firebug and in greasemonkey script):
这是我用来在页面上的脚本将控制台 API 设置为空函数后恢复控制台 API 的 JavaScript 解决方法(在 Firefox 46 中工作,在 Firebug 和greasemonkey 脚本中测试):
function restoreConsole() {
var i = document.createElement('iframe');
i.style.display = 'none';
document.body.appendChild(i);
window.console = i.contentWindow.console;
i.parentNode.removeChild(i);
}
More info and credentials: Restoring console.log()
更多信息和凭据:恢复 console.log()
回答by Panta Alejandro
Right click over firebug console tab and uncheck "enabled" option (the first one).
右键单击萤火虫控制台选项卡并取消选中“启用”选项(第一个)。