IE9 中的控制台未定义错误

2022-01-11 00:00:00 console javascript internet-explorer-9

我有一个显示 SVG 图形的图形页面.我正在使用 Raphael 图形框架.该页面在 Firefox 中正确显示,此外,如果 F12 开发人员工具在 IE9 中设置为打开",则它可以正常工作.如果 F12 开发者模式关闭并且应用程序在清除浏览器缓存的情况下启动(模拟普通用户),则该地图显示 IE9 中的部分数据(它是一个节点链接图,它仅显示 12 个节点中的一个子节点).

I have a graphics page which shows SVG graphics. I am using Raphael graphics framework. The page displays properly in Firefox, Also if the F12 developer tools is set 'on' in IE9 it works fine. The map show partial data (its a node link diagram and it shows only one child node out of 12 nodes) in IE9 if the F12 developer mode is set off and application is started with browser cache cleared (simulating a general user).

更新:我保持​​调试器打开并显示错误控制台未定义".所以我认为这不是图形渲染问题,而且我没有明确使用控制台,也许思维导图js在内部使用它,但是如何再次摆脱这个问题?

Update: I kept the Debugger on and Shows me the error "Console is undefined". So I think its not a graphics rendering issue, and also I am not using the console explicitly, maybe the mindmap js is using it internally, but how to again get rid of this issue?

更新:我发现了问题并注释掉了 js 文件中的 console.log 条目.

Update: I found the issue and commented out the console.log entries from the js files.

谢谢.

推荐答案

可能您的代码或您正在调用的代码正在使用 console.log 或类似的东西.

Probably your code or the code you are calling is using console.log or something like it.

您可以在全局范围内添加此代码来为 IE(或任何不支持它的浏览器)创建一个虚拟包装器.在调用任何其他库之前,只需将以下代码放在某处:

You could add this code in the global scope to create a dummy wrapper for IE (or any browser that doesn't support it). Just put the following code somewhere before you call any other libraries:

if(!(window.console && console.log)) {
  console = {
    log: function(){},
    debug: function(){},
    info: function(){},
    warn: function(){},
    error: function(){}
  };
}

相关文章