1

In a javascript web app I am displaying a rather long table, filled with data coming from firebase, with code like the following.

̧  const dbReference = firebase.database().ref('MyCollection').child('CHD')

  dbReference.on('value', function(list) {
    list.forEach(function(item) {
      itemR = document.createElement('tr'),
      itemD = document.createElement('td'),
      .... useful code laying out the item inside the table ....
    }
  }

It works as expected and I end up with my list of items in a table. But I need something more.

How can I make the window scroll automatically to a given position. For instance, to have the 157th item in the list to show at the top of the window. I have already searched the net and found some scroll functions that I tried, but with no success.

Note that the similar question (JavaScript to scroll long page to DIV) does not solves the problem. Maybe because it is a table.

I have tried to follow the solution provided there, using various options, but could not make it work.

Michel
  • 10,303
  • 17
  • 82
  • 179

0 Answers0