简体   繁体   English

退出弹出窗口无法正常工作

[英]Exit PopUp doesn't work properly

So guys, I have an exit PopUp it already worked but when I scroll down the site page down, it can't appear again. 伙计们,我有一个退出PopUp,它已经可以工作了,但是当我向下滚动网站页面时,它不会再次出现。 please help me find the problem. 请帮助我发现问题。 I really don't know what's wrong. 我真的不知道怎么了 well thx, sorry for bad English 谢谢,不好意思的英语

<script type="text/javascript" src="asset/jquery.min.js"></script>
<script type="text/javascript">
      $(function(){
        $(document).mousemove(function(e) {     
            $('#exitpopup').css('left', (window.innerWidth/2 - $('#exitpopup').width()/2));
            $('#exitpopup').css('top', (window.innerHeight/2 - $('#exitpopup').height()/2));
            if(e.pageY <= 5)
            {
                // Show the exit popup
                $('#exitpopup_bg').fadeIn();
                $('#exitpopup').fadeIn();
            }
        });
        $('.close').click(function(){
        $('#exitpopup_bg').fadeOut();
            $('#exitpopup').fadeOut();
    });
        $('#exitpopup_bg').click(function(){
            $('#exitpopup_bg').fadeOut();
            $('#exitpopup').slideUp();
        });
    });

</script>
<style type="text/css">
    #exitpopup{
        text-align:center;
    }
    #exitpopup h1{
        margin-top:0px;
        padding-top:0px;    
    }   
    #exitpopup p{
        text-align:left;
    }
</style>
<div style="display: none; width:100%; height:100%;  position:fixed; background:black; opacity: .3; filter:alpha(opacity=0.8); z-index:999998;" id="exitpopup_bg">

</div>
    <div style="width:50%; height:auto; margin:0px auto; display:none;position:fixed; color:#ffffff; padding:20px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; z-index:999999;" id="exitpopup">
    <img src="asset/PopUp.png" />           
</div>

The problem is in 问题出在

if(e.pageY <= 5)

you can't catch the e.pageY <= 5 after scroll .. so you need 滚动后无法捕获e.pageY <= 5 ,因此您需要

if(e.pageY - $(window).scrollTop() <= 5)

Demo Here 在这里演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM