Google Chrome框架叠加仅适用一次 [英] Google chrome frame overlay works only once

查看:126
本文介绍了Google Chrome框架叠加仅适用一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a page that prompts for a Google Chrome Frame installation if the user uses an outdated browser.

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

It works great if the user chooses to install the plugin. But, if he/she choose not to install it and closed the layer; It's impossible to open the layer again using the same button. (Basically it works only once.)

我是否可以在每次点击安装时强制Google Chrome Frame打开? < br>
(我试过强制cookie,但似乎没有用。)

Is there any way I can force Google Chrome Frame to open every time I click on install?
(I've tried forcing a cookie, but doesn't seem to work.)

测试页面此处

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



这似乎是与会话相关的问题

当我重新启动浏览器时,该链接再次运行一次。但是当我只刷新页面时却不会。

update [#2]:

This seem to be a session-related problem.
When i restart the browser, the link works again once. But doesn't however when i only refresh the page.

此行为是设计。它允许管理员在每个页面上为GCF提供 check(),而不会每次都向用户发出提示。

This behavior is by design. It allows an admin to check() for GCF on every single page, without annoying the user with a prompt every time.


接受的答案可以避免这种行为。



推荐答案

你对cookie是正确的,但是当它显示弹出窗口时,它也会设置一个私有变量,因此如果不破解cfinstall脚本,我们会考虑覆盖现有的方法。

You're right about the cookie, but it annoyingly also sets a private variable when it shows the popup, so without hacking the cfinstall script we're looking at overriding existing methods.

这是我能得到的最好的方法。有一个问题,按取消然后关闭意味着当你再次弹回它时弹出窗口仍然在第二页,但你可以从那里安装,所以我不认为这是一个大问题。 (我的学生不喜欢它!)

This is the best I can get. There's a problem where pressing "cancel" and then "close" means that the popup is still on the 2nd page when you pop it back up again, but you can install from there so I don't think it's that big an issue. (The pedant in me doesn't like it though!)

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

这篇关于Google Chrome框架叠加仅适用一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆