Using onbeforeunload without dialog?

前端 未结 5 685
死守一世寂寞
死守一世寂寞 2020-12-09 16:04

I\'m trying to post data when a user leaves my page. I have finally managed to find a working solution, however, it shows a confirmation dialog when the user leaves. I have

5条回答
  •  Happy的楠姐
    2020-12-09 16:44

    I have found a really simple trick to get this working with using

    $(window).bind('onbeforeunload', function () {
    
    $.post("track.php", {
    async: false,
    refid: refid,
    country: country, 
    type: type,
    });
    
    });
    

提交回复
热议问题