Javascript Console.log在Chrome或Firefox中不起作用
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Javascript Console.log在Chrome或Firefox中不起作用,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1747字,纯文字阅读大概需要3分钟。
内容图文
![Javascript Console.log在Chrome或Firefox中不起作用](/upload/InfoBanner/zyjiaocheng/659/7e7536a8aec24f7dbae69104122d22f3.jpg)
我做的很简单:
console.log("Testing");
随着 :
alert("testing");
警报有效(因此我知道javascript正在工作),但是我看不到日志.当我使用Firefox时,出现以下错误:
The Web Console logging API (console.log, console.info,
console.warn, console.error) has been disabled by a script on this
page.
到底是怎么回事?我查看了以下主题,但没有帮助:
Chrome: console.log, console.debug are not working
console.log quit working in Chrome
Console.log not working in Chrome [closed]
why does console.log not output in chrome?
Console.log not working at all
我还确保该漏斗正在运行并且已打开日志记录.
还有什么问题呢?
解决方法:
我在Firefox更新后才遇到此问题,并设法解决了该问题.这是导致问题的代码:
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var console = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = console;
}
在FireFox的先前版本中,“ var console;”不会被执行.现在,它似乎已经添加了某种分支/预测机制.看到我可以使用全局范围定义一个名为console的变量,它禁用了window.console.
我通过重命名var console来解决此问题;到var cons;
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var cons = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = cons;
}
不过,我仍然需要对此进行测试,以确保它能够达到我在IE中的预期.我只需要查找没有控制台的IE副本(我认为9或以下).
我只希望Firefox可以告诉您什么脚本禁用了控制台-那就太好了.
内容总结
以上是互联网集市为您收集整理的Javascript Console.log在Chrome或Firefox中不起作用全部内容,希望文章能够帮你解决Javascript Console.log在Chrome或Firefox中不起作用所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。