Can I force IE users to install Google Chrome Frame Plugin

Ed Sullivan picture Ed Sullivan · Sep 23, 2011 · Viewed 8.2k times · Source

I am using google visualization for charts, which doesn't render very well in IE8, and doesn't work at all in IE6.

I added google chrome frame, and if the user installs the plug-in google visualization works flawlessly.

Is there a way that I can force IE users to install GFC? Right now it is optional. I read the documentation, and there does not seem to be a way to configure this through the GFCInstall.check() function call.

Here is my current code:

<!--[if IE]>
    <script type="text/javascript" 
     src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>

    <style>
     .chromeFrameInstallDefaultStyle {
       border: 5px solid blue;
        top:55%;
     }
    </style>



    <script>
     // The conditional ensures that this code will only execute in IE,
     // Therefore we can use the IE-specific attachEvent without worry
     window.attachEvent("onload", function() {
       CFInstall.check({
         mode: "inline" 
       });
     });
    </script>
  <![endif]-->

Answer

bobince picture bobince · Sep 23, 2011

It would almost certainly be better to do this via capability-sniffing. Assuming that the feature you need to get nice visualisations is <canvas> support, sniff for that rather than a specific browser:

if (!('width' in document.createElement('canvas'))) {
    document.write(
        'The visualisations on this page don\'t work well in your current browser. '+
        'Please upgrade to a modern browser such as IE9, Firefox, Opera, Safari or '+
        'Chrome, or install Chrome Frame for earlier IE versions.'
    );
}