使用此jQuery Plugin for Smart Exit Pop Behavior - Exit Popup,它在Chrome和IE中完美运行,但在FireFox中没有任何功能。
我有test page up here,我的代码在
之下关于问题是什么的任何想法?
<div style="display: none; width:100%; height:100%; position:fixed;background:#9fa1a3; opacity: .4; filter:alpha(opacity=0.8);z-index:999998;"id="exitpopup_bg"></div>
<div id="exitpopup">
<a href="#" class="close" data-dismiss="exitpopup" style="text-decoration:none;">
<span aria-hidden="true">X</span>
<span class="sr-only">Close</span>
</a>
<h1>Wait!!! Before you go...</h1>
<h2>Subscribe the Vortexx mailing list</h2>
<p class="cta">Get exclusive deals, discounts, and exclusive offers!</p>
<form action="//vortexxpressurewashers.us9.list-manage.com/subscribe/post?u=d291585f9a09bffe246d968b2&id=863cd3e992" method="post" class="validate" target="_blank" novalidate>
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter Your Email Address" required>
<input type="submit" value="Send me deals!" name="subscribe" id="mc-embedded-subscribe" class="button">
</form>
<a href="#" class="close" data-dismiss="exitpopup">
<span aria-hidden="true" style="font-size:14px;">No, thanks</span>
<span class="sr-only">Close</span>
</a>
</div>
var last_position = {};
$(document).on('mousemove', function (event) {
if (typeof(last_position.x) != 'undefined') {
var deltaX = last_position.x - event.offsetX,
deltaY = last_position.y - event.offsetY;
if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) {
//upward movement
if(event.pageY <= 5){
$('#exitpopup').css('left', (window.innerWidth/2 - $('#exitpopup').width()/2));
$('#exitpopup').css('top', (window.innerHeight/2 - $('#exitpopup').height()/2));
// Show the exit popup
$('#exitpopup_bg').fadeIn();
$('#exitpopup').fadeIn();
}
}
}
last_position = {
x : event.offsetX,
y : event.offsetY
};
});
$('#exitpopup_bg').click(function(){
$('#exitpopup_bg').fadeOut();
$('#exitpopup').slideUp();
});
答案 0 :(得分:0)
备注前两个条件并享受firefox也
例如:
*
var last_position = {};
$(document).on('mousemove', function (event) {
//if (typeof(last_position.x) != 'undefined') {
//var deltaX = last_position.x - event.offsetX,
// deltaY = last_position.y - event.offsetY;
// if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) {
//upward movement
if(event.pageY <= 5){
$('#exitpopup').css('left', (window.innerWidth/2 - $('#exitpopup').width()/2));
$('#exitpopup').css('top', (window.innerHeight/2 - $('#exitpopup').height()/2));
// Show the exit popup
$('#exitpopup_bg').fadeIn();
$('#exitpopup').fadeIn();
}
// }
//}
last_position = {
x : event.offsetX,
y : event.offsetY
};
});
$('#exitpopup_bg').click(function(){
$('#exitpopup_bg').fadeOut();
$('#exitpopup').slideUp();
});
*