Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda