【问题标题】:Google chrome frame overlay works only once谷歌 chrome 框架覆盖只工作一次
【发布时间】:2012-02-06 21:10:15
【问题描述】:

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

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

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

更新[#1]:

测试页面here

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

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

[结论]

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

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

【问题讨论】:

    标签: javascript jquery internet-explorer google-chrome-frame


    【解决方案1】:

    您对 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>
    

    【讨论】:

    • +1 我的书呆子也不喜欢它 :) 但它成功了。干杯!
    • 嘿——不客气,伙计。如果我想出任何解决方案,那么我会更新答案。
    猜你喜欢
    • 1970-01-01
    • 2011-05-18
    • 1970-01-01
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    • 2017-04-09
    • 2019-11-29
    相关资源
    最近更新 更多