'免费下载'Chrome问题 [英] 'beforeunload' Chrome Issue

查看:102
本文介绍了'免费下载'Chrome问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $(window).bind('beforeunload',function(){ 
alert(Good Bye)
});

非常适合Firefox,IE8,但不适用于Chrome。这是一个已知的问题,或者有什么替代方案?



其实我试图做的是每当用户尝试关闭浏览器时记录详细信息。

 函数LogTime()
{
jQuery.ajax({
type:POST,
url:log.php,
data:,
cache:false,
success:function(response)
{
}
);

$ b $(window).bind('beforeunload',function(){
LogTime();
});

这适用于Firefox,但不适用于Chrome

  $(window).on( 'beforeunload',function(){
returnGood bye;
});


I have this simple piece of code -

$(window).bind('beforeunload', function(){
    alert("Good Bye")
});

Works great with Firefox, IE8 but not in Chrome. Is it a known problem or is there any alternative for that ?

Actually what I am trying to do is to log details whenever user tries to close the browser.

function LogTime()
{
    jQuery.ajax({
      type: "POST",
      url: "log.php",
      data: "",
      cache: false,
      success: function(response)
      {
      }
    );
}

$(window).bind('beforeunload', function(){
    LogTime();
});

This works well in Firefox, but not in Chrome

解决方案

Return a string instead:

$(window).on('beforeunload', function(){
    return "Good bye";
});​

这篇关于'免费下载'Chrome问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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