1

We have inhouse library which uses canvas for displaying charts in my application. And dojo as scripting language.Everything is fine, but my charts are not appearing in IE8. I google about this, and found that there is some VML issue in IE8.

I found this:

var printChart = function(time, freq){
    if (!document.namespaces['g_vml_']) {
            document.namespaces.add('g_vml_', 'urn:schemas-microsoft-com:vml', '#default#VML');
        }

        if (!document.namespaces['g_o_']) {
            document.namespaces.add('g_o_', 'urn:schemas-microsoft-com:office:office', '#default#VML');
        }

 if (freq === undefined) {
        this.freq = "1mi";
    }

    if (time === undefined) {
        this.time = "1dy";
    }
self.reload();
}

Now I was trying to add this in my DOJO code and that is creating problem. As when I do document.namespace I get firebug error 'document.namespaces is undefined'.

Q: How can we fix this, are the any better alternative approaches for the same, basic problem am having is browser related, charts are rendered properly on other browsers but not on IE8, any suggestions ?

Update:

What are ways to deal with such cross browser issue ?

Rachel
  • 100,387
  • 116
  • 269
  • 365

1 Answers1

0

Regarding the cross-browser issues you mentioned, there are basically two ways: browser sniffing and object detection. Browser sniffing is to detect the browser vendor and version. For example, you can know that the browser is IE 8 or Firefox 4.0 from the navigator object. Object detection is to test whether a object/function is available on the browser before actually using it.

For the problem you have here, you can use the two approaches. For example, you can sniff the browser using dojo.isIE.

if (dojo.isIE == 8) {
    //Your code to add the namespace
}

Or you can use:

if (document.namespaces) {
   // Your code to add the namespace
}
Fu Cheng
  • 3,385
  • 1
  • 21
  • 24