簡體   English   中英

退出彈出窗口無法正常工作

[英]Exit PopUp doesn't work properly

伙計們,我有一個退出PopUp,它已經可以工作了,但是當我向下滾動網站頁面時,它不會再次出現。 請幫助我發現問題。 我真的不知道怎么了 謝謝,不好意思的英語

<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>

問題出在

if(e.pageY <= 5)

滾動后無法捕獲e.pageY <= 5 ,因此您需要

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

在這里演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM