Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
JS avoid popup blocker

I have an pop-under. It opens a duplicate of current page and redirects old page to google.com. Also it is working once a day (with cookies). But every time it is blocking with popup blocker. I heard that I can avoid it with execution function on user interact so I added onscroll function:

document.addEventListener('scroll', function() {
function setCookie(cname,cvalue,exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires=" + d.toGMTString();
    document.cookie = cname+"="+cvalue+"; "+expires;
}

function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}

function showOnceInADay() {
    var user=getCookie("username1");
    if (user != "") {
    } else {
        window.open(window.location.href);window.location.href='https://www.google.com/';
           setCookie("username1", 1, 1);
    }
}


jQuery(document).ready(function($) {
        showOnceInADay() ;
});
})

How can I avoid it in another way? I've read answers to this question Avoid browser popup blockers but Can I do this without onclick event? Pop-under should be opened in first user interactive with a page

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!