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

139
Visualizações
Webpage scrolls up when button is clicked

I'm building a webpage with ASP.net where, when the button at the top of the page, it automatically scrolls down to a certain :

<script>
      function myFunction() {
         const element = document.getElementById("Results");
         element.scrollIntoView({behavior: 'smooth'});
      }
</script>

But unfortunately, it goes back up again after the click. I have tried a number of solutions, like:

<script type="text/javascript">
 var xPos, yPos;
 var prm = Sys.WebForms.PageRequestManager.getInstance();
 prm.add_beginRequest(BeginRequestHandler);
 prm.add_endRequest(EndRequestHandler);
 function BeginRequestHandler(sender, args) {
     xPos = $get('scrollDiv').scrollLeft;
     yPos = $get('scrollDiv').scrollTop;
 }
 function EndRequestHandler(sender, args) {
     $get('scrollDiv').scrollLeft = xPos;
     $get('scrollDiv').scrollTop = yPos;
}
</script>

or

MaintainScrollPositionOnPostback="true"

but to no avail.

My button is coded as:

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" 
        OnClientClick="myFunction()" Visible="true" Style="display: none" />

What other solutions should I try to implement?

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