Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
Saltar al lado derecho de la página html

Tengo una página HTML con una tabla grande y muchas columnas, necesito desplazarme hacia la derecha de la página automáticamente al cargar la página.

He probado este código pero no me funciona:

 </script><script type="text/javascript"> var myDiv = document.getElementById('containerDiv'); myDiv.innerHTML = variableLongText; myDiv.scrollRight = 0; </script>

¿Es un enfoque correcto para desplazarse automáticamente por la página?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puedes probar este código.

 <script type="text/javascript"> var myDiv = document.getElementById('containerDiv'); myDiv.scrollTo(0, myDiv.scrollRight) </script>
about 4 years ago · Juan Pablo Isaza Report

0

Prueba así:

 // Getting div from DOM const myDiv = document.getElementById('containerDiv'); // Getting div's position divRect = myDiv.getBoundingClientRect(); // Scrolling to div's position window.scrollTo({ top: divRect.top, left: divRect.left, // behavior: 'smooth' }); /* behavior: 'smooth' will give a smooth sensation with a slow transition on scroll. I would personally recommend using it (mainly if this is not intended to run on load). */

Mejor y sin comentarios:

 const divRect = document.getElementById('containerDiv').getBoundingClientRect(); window.scrollTo({ top: divRect.top, left: divRect.left });

Para obtener información sobre getBoundingClientRect() , consulte este artículo https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

about 4 years ago · Juan Pablo Isaza Report

0

si desea desplazarse por la ventana, utilice

 window.scrollTo(x-axis,y-axis);

o para uso div específico

 document.getElementById('container').scrollLeft += 10000;

tan completo programa ser como

 window.onload = function() { // for specific div document.getElementById('nan').scrollLeft += 100000; //for window /* window.scrollTo(10000, 0) */; };

también puede ver el ejemplo https://jsfiddle.net/zcmhp2de/38/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!