www.webdeveloper.com
Results 1 to 4 of 4

Thread: how to use scrollIntoView on dynamic HTML Elements

  1. #1
    Join Date
    Dec 2012
    Posts
    4

    how to use scrollIntoView on dynamic HTML Elements

    Hey,

    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!

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,270
    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 !

  3. #3
    Join Date
    Dec 2012
    Posts
    4
    Quote Originally Posted by 007Julien View Post
    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?

  4. #4
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,270
    «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».

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles