admin管理员组文章数量:1289586
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.)
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.)
update [#1]:
Test page here.
<!doctype html>
<html>
<head>
<script src=".7.1/jquery.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src=".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: '.html?user=true',
mode: "overlay",
destination: ""
});
});
}else{
alert('GCF is already installed');
}
}else{
alert('You need IE 6, 7 or 8 in order to see the "bug".');
}
});
</script>
</body>
</html>
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.
[conclusion]
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.
The accepted answer allows you to circumvent this behavior.
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.)
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.)
update [#1]:
Test page here.
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis./ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="http://ajax.googleapis./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./chromeframe/eula.html?user=true',
mode: "overlay",
destination: "http://mywebsite."
});
});
}else{
alert('GCF is already installed');
}
}else{
alert('You need IE 6, 7 or 8 in order to see the "bug".');
}
});
</script>
</body>
</html>
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.
[conclusion]
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.
Share Improve this question edited Jan 17, 2012 at 12:19 Pierre asked Jan 10, 2012 at 12:52 PierrePierre 19.1k5 gold badges43 silver badges62 bronze badgesThe accepted answer allows you to circumvent this behavior.
1 Answer
Reset to default 9 +50You'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./ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="http://ajax.googleapis./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./chromeframe/eula.html?user=true",
mode: "overlay",
destination: "http://mywebsite."
});
$("#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>
本文标签: javascriptGoogle chrome frame overlay works only onceStack Overflow
版权声明:本文标题:javascript - Google chrome frame overlay works only once - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741476795a2380932.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论