how to use scrollIntoView on dynamic HTML Elements
in my script I am adding div elements dynamically to the DOM. After creation I want the browser to scroll them into view using JS function scrollIntoView.
The problem is that calling scrollIntoView right after calling document.body.appendChild(newElement) doesn't work.
Looking forward to your help!
Several times, this genre of problem can be solved with a setTimeout to execute the scroll some milliseconds after the end of the script. Still the page has to can scroll !
Thanks, setting Timeout solved my problem but is there no better solution for that?
Originally Posted by 007Julien
«Delaying the execution (even by 0 miilliseconds) allows screen updates to occur before the processing begin !» It's not necessary a bad solution ! Read, for example, this page «Processing vs Responsiveness».
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)