Vertical scrollbar position in a table
I need your help.
The following javascript coding, that works flawlessly when it is
executed, however, the coding starts off the scroll position to the bottom
of my data table.
How can the javascript coding be modified so as to start at the top instead?
var table = document.getElementById("data");
var rows = table.getElementsByTagName("tr");
if (table.parentNode.scrollTop + table.parentNode.offsetHeight -
rows[0].offsetHeight < rows[i].offsetTop + rows[i].offsetHeight ||
rows[i].offsetTop < table.parentNode.scrollTop + rows[0].offsetHeight) {
table.parentNode.scrollTop = rows[i].offsetTop -
table.parentNode.offsetHeight / 2;
}
No comments:
Post a Comment