18

如果用户使用过时的浏览器,我有一个页面会提示安装Google Chrome Frame 。

如果用户选择安装插件,它会很好用。但是,如果他/她选择不安装并关闭该层;使用相同的按钮再次打开图层是不可能的。(基本上它只工作一次。)

每次点击安装时,有什么方法可以强制打开 Google Chrome Frame?
(我试过强制使用 cookie,但似乎没有用。)

更新 [#1]:

测试页面在这里

<!doctype html>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <!--[if IE]>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <a href="#" class="dngcf">Prompt</a>
        <script>
            $(function(){
                if( $.browser.msie && $.browser.version < 9 ){
                    if( navigator.userAgent.indexOf('chromeframe') < 0 ){
                        $('.dngcf').bind('click', function(){
                            //document.cookie = 'disableGCFCheck=0;path=/;';
                            CFInstall.check({
                                url: 'http://www.google.com/chromeframe/eula.html?user=true',
                                mode: "overlay",
                                destination: "http://mywebsite.com"
                            });
                        });
                    }else{
                        alert('GCF is already installed');
                    }
                }else{
                    alert('You need IE 6, 7 or 8 in order to see the "bug".');
                }
            });
        </script>
    </body>
</html>

更新[#2]:

这似乎是一个与会话相关的问题
当我重新启动浏览器时,链接再次工作一次。但是当我只刷新页面时不会。

[结论]

这种行为是设计使然。它允许管理员check()在每个页面上使用 GCF,而不会每次都用提示来烦扰用户。

接受的答案允许您规避这种行为。

4

1 回答 1

9

您对 cookie 的看法是正确的,但令人讨厌的是,它在显示弹出窗口时也会设置一个私有变量,因此在不破解 cfinstall 脚本的情况下,我们正在研究覆盖现有方法。

这是我能得到的最好的。有一个问题,按“取消”然后“关闭”意味着当您再次弹出它时弹出窗口仍在第二页上,但您可以从那里安装,所以我认为这不是什么大问题。(虽然我的书呆子不喜欢它!)

<!doctype html>
<html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <!--[if IE]>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <a href="#" class="dngcf">Prompt</a>
        <script>
            $(function(){
                if ($.browser.msie && $.browser.version < 9){
                    if (navigator.userAgent.indexOf("chromeframe") < 0){
                        $(".dngcf").on("click", function(){
                            if ($(".chromeFrameOverlayContent").length > 0) {
                                $(".chromeFrameOverlayContent, .chromeFrameOverlayUnderlay").show();
                            } else {
                                CFInstall.check({
                                    url: "http://www.google.com/chromeframe/eula.html?user=true",
                                    mode: "overlay",
                                    destination: "http://mywebsite.com"
                                });
                                $("#chromeFrameCloseButton").off("click").on("click", function() {
                                    $(".chromeFrameOverlayContent, .chromeFrameOverlayUnderlay").css({ display: "none" });
                                });
                            }
                        });
                    } else {
                        alert('GCF is already installed');
                    }
                } else {
                    alert('You need IE 6, 7 or 8 in order to see the "bug".');
                }
            });
        </script>
    </body>
</html>
于 2012-01-12T14:19:38.743 回答