Can I force IE users to install Google Chrome Frame Plugin
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() {
CFIns开发者_JAVA百科tall.check({
mode: "inline"
});
});
</script>
<![endif]-->
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.'
);
}
No you cannot force the user - your best options from the Google Chrome Frame FAQ:
How do I tell if a user has Google Chrome Frame installed?
Google Chrome Frame adds a ‘chromeframe/X.X.X.X’ token to the User-Agent header so you can check for its presence that way. If Google Chrome Frame isn’t present, you can choose to either prompt or show fallback content. See http://www.chromium.org/developers/how-tos/chrome-frame-getting-started/understanding-chrome-frame-user-agent for more information on the User-Agent header.
We've also provided a JavaScript library you can use to test whether Google Chrome Frame is installed and if not, to prompt the user to install it. See http://www.chromium.org/developers/how-tos/chrome-frame-getting-started for more details on how to use and customize the JavaScript library.
精彩评论