当鼠标指针离开浏览器页面时,弹出屏幕将被触发。当我再次进入浏览器页面时,弹出屏幕应该会消失,但是现在我必须单击弹出窗口中的关闭按钮来删除它。
当您再次进入浏览器页面时,如何才能将弹出窗口消失?
我使用了这个Javascript代码:
// Exit intent
function addEvent(obj, evt, fn) {
if (obj.addEventListener) {
obj.addEventListener(evt, fn, false);
} else if (obj.attachEvent) {
obj.attachEvent("on" + evt, fn);
}
}
// Exit intent trigger
addEvent(document, 'mouseout', function(evt) {
if (evt.toElement == null && evt.relatedTarget == null) {
$('.lightbox').slideDown();
};
});
// Closing the Popup Box
$('a.close').click(function() {
$('.lightbox').slideUp();
});发布于 2016-12-03 02:29:21
通过mouseover事件触发它。
addEvent(document, 'mouseover', function(evt) {
if (evt.toElement == null && evt.relatedTarget == null) {
$('.lightbox').slideUp();
};
});https://stackoverflow.com/questions/40942461
复制相似问题