我可以强制 IE 用户安装 Google Chrome 内嵌框架插件吗

发布于 2024-12-06 13:31:13 字数 828 浏览 1 评论 0原文

我正在使用谷歌可视化图表,它在 IE8 中渲染得不太好,在 IE6 中根本不起作用。

我添加了谷歌浏览器框架,如果用户安装插件谷歌可视化可以完美地工作。

有没有办法强制 IE 用户安装 GFC?现在它是可选的。我阅读了文档,似乎没有办法通过 GFCInstall.check() 函数调用来配置它。

这是我当前的代码:

<!--[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]-->

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]-->

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴骨ら 2024-12-13 13:31:13

几乎可以肯定,通过能力嗅探来做到这一点会更好。假设获得良好可视化效果所需的功能是 支持,请嗅探该功能而不是特定的浏览器:

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.'
    );
}

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.'
    );
}
前事休说 2024-12-13 13:31:13

不,你不能强迫用户 - 你的最佳选择来自 Google Chrome 浏览器内嵌框架常见问题解答

如何判断用户是否安装了 Google Chrome 浏览器内嵌框架?

Google Chrome 浏览器内嵌框架会在 User-Agent 标头中添加“chromeframe/XXXX”令牌,以便您可以通过这种方式检查其是否存在。如果 Google Chrome 浏览器内嵌框架不存在,您可以选择提示或显示后备内容。请参阅 http:// www.chromium.org/developers/how-tos/chrome-frame-getting-started/understanding-chrome-frame-user-agent 有关 User-Agent 标头的更多信息。

我们还提供了一个 JavaScript 库,您可以用它来测试是否安装了 Google Chrome 浏览器内嵌框架,如果没有安装,则提示用户进行安装。请参阅 http://www.chromium.org/developers/how- tos/chrome-frame-getting-started 了解有关如何使用和自定义 JavaScript 库的更多详细信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文