Click here to Skip to main content
15,885,048 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 popups on my website, 1st popup comes after 3 sec of page load, and 2nd popup comes when the user tries to leave the website. all things work fine. But when the user tries to fill the form from 1st popup auto suggestions come for input, when the user hovers over the auto-suggestion the exit intent popup comes, which is making a bad user experience. I don't want to close autosuggestion because it makes it easy for users to fill out forms fast. I'm trying to disable another popup till 1st popup is visible

What I have tried:

Below is an exit intent popup code
JavaScript
var c, a = window.location.pathname,
d = a.substring(a.lastIndexOf("/") + 1);
if (d !== "thank-you.php") {
    function addEvent(obj, evt, fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evt, fn, false);
    } else if (obj.attachEvent) {
        obj.attachEvent("on" + evt, fn);
    }
}

addEvent(document, 'mouseout', function(evt) {
    if (evt.toElement == null && evt.relatedTarget == null) {
        if(sessionStorage["PopupShown"] != 'yes'){
            sessionStorage["PopupShown"] = 'yes';
         $('.lightbox').modal('show');
         $('#enqModal').modal('hide');
     }
    };
});


Below is the code in which I'm trying to disable the exit popup while 1st popup is visible

JavaScript
let m = document.querySelector("#enqModal").style.display;
if(m === 'block'){
    $('.lightbox').modal('hide');
}


please guide, how can i make this possible
Posted
Comments
Member 15627495 23-Oct-22 7:13am    
https://www.w3schools.com/tags/ref_eventattributes.asp

each events are in this page.
Richard Deeming 24-Oct-22 5:05am    
"... which is making a bad user experience ..."

And you don't think nagging them with popups as soon as they load your site, and again every time the mouse leaves your site, is bad enough already?

Any site that does that is likely to land on the "leave immediately and never visit again" list.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900