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

279
Visualizações
how to make a pop up appear only once in html using javascript

i have my age verification pop up i want to appear only once when the site is visited and the pop up keeps appearing each item i refresh my browser, how do i go about it? answer will be much appreciated.

if (document.getElementById("newsletter-popup-form")) {
  setTimeout(function () {
    var mpInstance = $.magnificPopup.instance;
    if (mpInstance.isOpen) {
      mpInstance.close();
    }

    setTimeout(function () {
      $.magnificPopup.open({
        items: {
          src: "#newsletter-popup-form",
        },
        type: "inline",
        removalDelay: 350,
        callbacks: {
          open: function () {
            $("body").css("overflow-x", "visible");
            $(".sticky-header.fixed").css("padding-right", "1.7rem");
          },
          close: function () {
            $("body").css("overflow-x", "hidden");
            $(".sticky-header.fixed").css("padding-right", "0");
          },
        },
      });
    }, 500);
  }, 100);
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

HTML

<!--(place this inside the popup)-->
<input id="age-input" />

JS

const popup = document.getElementById("newsletter-popup-form")
const ageInput = document.getElementById("age-input")

ageInput.addEventListener(change, (e) => {
  localStorage['userAge'] = ageInput.value;
}

if if (localStorage.getItem("userAge") === null) { {
   // shows the popup on refresh so long as variable is not found
   popup.style.display="block";
   //insert any additional code here...
} else {
   // hides the popup
   popup.style.display="none";
}
about 4 years ago · Juan Pablo Isaza Relatório
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