用户想要退出时的Html弹出窗口

时间:2014-06-29 15:58:42

标签: javascript jquery html

我有这个javascript代码,当用户将鼠标移出文档时,会启动退出弹出式html代码(div - #exitpopup_bg和#exitpopup)。我希望它仅在用户想要离开页面时启动(当用户想要关闭选项卡时)。另外我想同时加载我的html代码和浏览器警报。任何帮助将受到高度赞赏。

<script type="text/javascript">

$(document).ready(function() {
var counter=0;
    $(document).mousemove(function(e) {

        $('#exitpopup').css('left', (window.innerWidth/2 - $('#exitpopup').width()/2));
        $('#exitpopup').css('top', (window.innerHeight/2 - $('#exitpopup').height()/2));

        if(counter ==0 && e.clientY <= 30)


        {
            // Show the exit popup
            $('#exitpopup_bg').fadeIn();
            $('#exitpopup').fadeIn();   
            counter++;
}



    });

    $('#xmark').click(function(){
        $('#exitpopup_bg').fadeOut();
        $('#exitpopup').slideUp();
    }); 

});
</script>

因此,当用户在页面选项卡上单击x时,我想启动警报和此

 $('#exitpopup_bg').fadeIn();
 $('#exitpopup').fadeIn();  

您可以看到它目前的工作方式:http://www.brzedijete.com/test/rezultatiFUe.php 将光标移动到文档顶部,弹出消息,只有当用户想要关闭标签/页面时才需要弹出该消息。

0 个答案:

没有答案