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

105
Visualizações
Is there a possibility with javascript to show a scroll hint only at the first pageload?

I have created a simple scroll hint which disappears by mousedown. My goal is that the hint is only displayed the first time. When I reload the page, it should not be displayed again. Only again when the cache of the web page is cleared.

Is there a simple way to realise it with javascript?

function hideHint() {
  document.getElementById("scroll-hint").style.display = "none";
}
body {
  margin: 0;
}

#content {
  background-color: orange;
  height: 100vh;
  width: 100vw;
}

#scroll-hint {
  background-color: gray;
  border-style: solid;
  height: 20vh;
  width: 20vw;
  align-items: center;
  display: flex;
  justify-content: center;
  position: fixed;
  left: 40%;
}

.mouse {
  display: block;
  width: 23px;
  height: 40px;
  border-radius: 13px;
  border: 2px solid blue;
  position: absolute;
  left: 50%;
  margin: 0 auto 0 -14px;
  background-color: white;
}

span {
  display: block;
  margin: 6px auto;
  width: 3px;
  height: 7px;
  border-radius: 100%;
  background: blue;
}
<div id="content" onmousedown="hideHint()">
  <div id="scroll-hint">
    <div class="mouse">
      <span></span>
    </div>
  </div>
</div>

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

0

I would use localStorage for that.

function hideHint() { document.getElementById("scroll-hint").style.display = "none"; localStorage.setItem('scrollHint', 'is_seen') }

if(localStorage.getItem("scrollHint"));

function hideHint() {
  document.getElementById("scroll-hint").style.display = "none";
  localStorage.setItem('scroll_hint', true);
}

if (localStorage.getItem('scroll_hint')) {
  document.getElementById("scroll-hint").style.display = "none";
}
body {
  margin: 0;
}

#content {
  background-color: orange;
  height: 100vh;
  width: 100vw;
}

#scroll-hint {
  background-color: gray;
  border-style: solid;
  height: 20vh;
  width: 20vw;
  align-items: center;
  display: flex;
  justify-content: center;
  position: fixed;
  left: 40%;
}

.mouse {
  display: block;
  width: 23px;
  height: 40px;
  border-radius: 13px;
  border: 2px solid blue;
  position: absolute;
  left: 50%;
  margin: 0 auto 0 -14px;
  background-color: white;
}

span {
  display: block;
  margin: 6px auto;
  width: 3px;
  height: 7px;
  border-radius: 100%;
  background: blue;
}
<div id="content" onmousedown="hideHint()">
  <div id="scroll-hint">
    <div class="mouse">
      <span></span>
    </div>
  </div>
</div>

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