Google chrome frame overlay works only once

房东的猫 提交于 2019-12-02 22:34:01

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!