最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

dictionary - Javascript "unspecified error" in Open Layers - Stack Overflow

programmeradmin3浏览0评论

I am getting this error alt text .png when the map loads.

The error is in the original, unmodified OpenLayers.js file on this line:

return!!(document.namespaces);

I have tried rewriting it to:

return (typeof(document.namespaces) != 'undefined');

and it worked but then I get same "unspecified" errors on further referrals to document.namespaces:

if(!document.namespaces.olv){document.namespaces.add("olv",this.xmlns); ...

I tried rewriting this to:

if(typeof(document.namespaces.olv) == 'undefined') { ...

but I get the same "unspecified error".

I only get this error on Internet Explorer (I tested on 7) and not in Firefox.

Any clues?

Thanks.

I am getting this error alt text http://img239.imageshack.us/img239/6936/jserror.png when the map loads.

The error is in the original, unmodified OpenLayers.js file on this line:

return!!(document.namespaces);

I have tried rewriting it to:

return (typeof(document.namespaces) != 'undefined');

and it worked but then I get same "unspecified" errors on further referrals to document.namespaces:

if(!document.namespaces.olv){document.namespaces.add("olv",this.xmlns); ...

I tried rewriting this to:

if(typeof(document.namespaces.olv) == 'undefined') { ...

but I get the same "unspecified error".

I only get this error on Internet Explorer (I tested on 7) and not in Firefox.

Any clues?

Thanks.

Share Improve this question asked Jul 4, 2009 at 8:44 AlinAlin 1711 silver badge7 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

The real problem is that document.namespaces is not ready in IE8 sometimes when triggering $(document).ready (because of VML)

You can use instead :

jQuery(window).load(function() {} ...);

I have found the solution.

The problem was that I was creating the map when the DOM was ready with Jquery:

$(document).ready(function(){  ... //create map here [WRONG]

All you have to do is to create the map after the onload event:

window.onload = function() { ... // create map here [CORRECT]

The problem with Internet Explorer is that when the page hits the document ready or the window onload, that M$ browser cannot determine the dimensions of the map canvas yet. If you want to work around this, you might also consider setting your map div dimensions:

<div id="map" style="width:250px;height:250px"></div>
发布评论

评论列表(0)

  1. 暂无评论