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

263
Visualizações
I want an Alert page depending the window size

I am trying to make a webpage now and I want to show my content with limt of size. For example if width over 1000px and height over 1000 px than Alert page shows up. And if window size is width < 1000 px and height < 1000px than Alert page hidden and content will show. Now I made a that say your screen is too big and makes this full size of webpage And with Javascript I gave a condition that can check size of window and if it feets than class hidden that has display: hidden will add or delete. this is my javascript code

const width = window.innerWidth;
const height = window.innerHeight;

//in the html there is no class: hidden. So alert page is show default.

function removeSizeAlert() {
  const sizeAlert = document.querySelector(".too-bgsm-size");
  sizeAlert.classList.add("hidden");
}

function addSizeAlert() {
  const sizeAlert = document.querySelector(".too-bgsm-size");
  sizeAlert.classList.remove("hidden");
}

function init() {
  if (width < 600 && height > 950) {
    removeSizeAlert();
  } else {
    addSizeAlert();
  }
}

init();

In here I want to make this more interactive. Now this code works only when I represh the page. But I want when page resize than detect the size change event and add or delete class hidden simultaneously. There is a way to do like this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

use addEventListener()

window.addEventListener('resize', init);

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