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

304
Visualizações
How to go to particular section without scrolling behavior / Any alternative to scrollIntoView() without scroll behavior?

I am trying to create a page redirection to a particular section, i.e. I want to go to a particular anchor div on a page without scrolling behavior. However, I have a query string in the URL for pagination so the #id method failed for me. I tried "scrollIntoView()" but it contains the page scrolling behavior, which is undesired. May I ask if there is any alternative solution to this problem?

I am using Vue for the frontend & Codeigniter for the backend. Here is my code:

        mounted() {
            // anchorPageToProductList
            if (this.isOnQuery) {
                console.log('isOnQuery');
                this.scrollToProductList();
            } else {
                console.log('isNotOnQuery');
            }
            
        },
methods: {
   scrollToProductList(){
       window.addEventListener('DOMContentLoaded', () => {
       // scroll animation
       document.getElementById('product-list-anchor').scrollIntoView(true);
     });
},

Example of my URL case:

http://www.example.com/Product/list?search=&sort=3&type=-1&event%5B%5D=11&pagination=1

Thank you!!

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

0

I've tried to unset the scrolling behavior, allow the the page to jump to the desired section, then set back the smooth-scroll behavior. So It now works without the scrolling behavior. Thanks for all the comments:)

My code:

scrollToProductList(){

  window.addEventListener('DOMContentLoaded', () => {

      // select the whole html & disable smooth-scroll behavior in css
      let htmlElement = document.querySelector('html');
      htmlElement.style.scrollBehavior = 'auto';

      // go to the anchor point
      document.getElementById('product-list-anchor').scrollIntoView(true);

      // enable smooth-scroll behavior again
      htmlElement.style.scrollBehavior = 'smooth';

  });

}

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