如何阻止 OpenLayers 加载 firebug lite

发布于 2024-11-29 14:17:25 字数 406 浏览 2 评论 0原文

当我开始使用 OpenLayers 时,console.log 停止工作,并且我不断在 chrome 终端中收到此错误。

GET http://127.0.0.1/my/private/dir/undefined/firebug.html 404 (Not Found)

起初我没有意识到这是OL,所以我卸载了firebug lite插件。然后我检查了 OL 源并找到了它试图注入 firebug 的位置。

y=document.createElement("iframe");y.setAttribute("src",o+"/firebug.html");

除了修改源代码之外,还有其他方法可以阻止 OL 这样做吗?另外,它会覆盖 window.console

When I started working with OpenLayers, console.log stopped working and I kept getting this error in the chrome terminal.

GET http://127.0.0.1/my/private/dir/undefined/firebug.html 404 (Not Found)

At first I didn't realize it was OL so I uninstalled the firebug lite plugin. Then I checked the OL source and found where it's trying to inject firebug.

y=document.createElement("iframe");y.setAttribute("src",o+"/firebug.html");

Is there a way to prevent OL from doing that other than modifying the source. Also, it's overwriting window.console

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

荆棘i 2024-12-06 14:17:25

我遇到了同样的问题。
我暂时通过添加:

<script type="text/javascript">
        console.firebug=true;//fix the openlayer problem
</script>

在加载 openlayer 脚本之前修复了它。

原因:
console.log 曾经在 Openlayer 的早期版本中工作,但现在不行,所以我检查了源代码,发现有:

if (!window.console || !console.firebug) { ...

这意味着我猜如果没有 FIREBUG 控制台,控制台将被清理并覆盖。

我认为这应该是一个bug,所以我就没有进一步研究这个,并尝试尽快修复它,等待Openlayer家伙修复bug。

希望它对你有用,如果没有,请告诉我。

I met the same problem.
I fixed it for the moment by adding:

<script type="text/javascript">
        console.firebug=true;//fix the openlayer problem
</script>

before loading the openlayer script.

the reason:
console.log used to work in the previous version of Openlayer ,but not for now, so I checked the source code found there is:

if (!window.console || !console.firebug) { ...

which means I guess if there is no FIREBUG console, the console will be cleaned up and overwritten.

I think it should be a bug , so I just didn't get further into this, and try to fix it as soon as possible, waiting for the bug fixed by the Openlayer guy.

hope it work for you, if not,please let me know.

有木有妳兜一样 2024-12-06 14:17:25

您是否在代码中包含像 firebug.js 这样的外部文件或类似的文件。我认为它不应该默认执行任何操作,并且它必须使用 hv sm 代码来检查范围内是否存在某些对象或其他内容。

希望您没有使用一些示例代码,这就是您面临此问题的原因。

还要确保您拥有正确的 OL 版本,而不是修补版本或测试版。
请更新我们的情况。

我找到的链接: http://osgeo-org.1803224.n2.nabble.com/Firebug-Error-Invalid-Object-Initializer-td2866563.html

顺便说一句,这是 openlayers 的立场:
添加 OpenLayers.Console 命名空间和许多允许记录错误消息的方法 - 当页面中包含 firebug.js 时,应用程序以“调试”模式运行 - Firebug 扩展或 Firebug Lite 处理 OpenLayers.Console 调用,具体取决于可用性

are you including an external file like firebug.js or something like that in the code.. I dont think it should do anything by defualt and it must hv sm code that checks if a certain objects exists in the scope or something.

Hope you are not using some example code and that is why you are facing this issue.

also make sure that you have the irght version of OL and not a patched version or a beta version.
please update us.

A link that I found: http://osgeo-org.1803224.n2.nabble.com/Firebug-Error-Invalid-Object-Initializer-td2866563.html

btw this is openlayers stand on it:
add OpenLayers.Console namespace and a number of methods that allow for logging of error messages - when firebug.js is included in a page, the application runs in "debug" mode - the Firebug extension or Firebug Lite handles OpenLayers.Console calls depending on availability

微凉徒眸意 2024-12-06 14:17:25

我最终只是注释掉了添加 iframe 的行。我在 OpenLayers 之前加载一个脚本,该脚本创建 window.console 的备份。

window.console2 = {};
for(key in window.console)
    window.console2[key] = window.console[key];

I ended up just commenting out the line that adds the iframe. And I load a script before OpenLayers which creates a backup of window.console.

window.console2 = {};
for(key in window.console)
    window.console2[key] = window.console[key];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文