开发者

How to stop OpenLayers from loading firebug lite

开发者 https://www.devze.com 2023-03-28 17:08 出处:网络
When I started working with OpenLayers, console.log stopped working and I kept getting this error in the chrome terminal.

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 so开发者_如何学Pythonurce. Also, it's overwriting window.console


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.


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


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];
0

精彩评论

暂无评论...
验证码 换一张
取 消