[mapguide-users] Re: Scalebar: TypeError, Fusion Error, and NS_ERROR_DOM_INVALID_ACCESS_ERR

Berg, Leandros van den [FGSBV] L.vdBerg at fugro.nl
Thu Nov 10 06:02:03 EST 2011


Hi Jamo,

I think the double quotations are optional within url() and adding them,
unfortunately, didn't solve NS_ERROR_DOM_INVALID_ACCESS_ERR. That same
line was throwing me a NS_ERROR_DOM_SECURITY_ERR with Firefox.
Apparently that error is thrown when the file comes from a different
domain, which it wasn't, so I caught the error and appended the
stylesheet to the header as a link element like so:

try {
  document.styleSheets[0].insertRule('@import url('+url+');',0);
}
  catch (err) {
    switch (err.name) {
      case 'NS_ERROR_DOM_SECURITY_ERR':
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.type = 'text/css';
      link.href= url;
      document.getElementsByTagName('head')[0].appendChild(link);
      break;
    default:
      console.log(err);
  }
}

For some reason, even before I added your double quotations, it isn't
throwing the NS_ERROR_DOM_SECURITY_ERR anymore, maybe something was
fixed in Firefox 8 or came to it's senses and seeing the file was on the
same domain after all.

By the way, to catch the NS_ERROR_DOM_INVALID_ACCESS_ERR I've replaced
this line in the bind APIFunction in OpenLayers.js

    return func.apply(object, newArgs);

With a try-catch block

try {
  return func.apply(object, newArgs);
}
catch (err) {
  console.log(err);
}

To make it a bit more interesting if you like, as stated in the comments
of scalebar.js, when I put a breakpoint somewhere, the scalebar is shown
but with the wrong label, and the NS_ERROR_DOM_INVALID_ACCESS_ERR is
thrown, and the TypeError is back. Some piece of wizardries at work here
or maybe an undocumented feature.

Leandros


More information about the mapguide-users mailing list