function scrollTo(row) { var container = document.getElementById("superHappyFunDiv"); var rows = container.getElementsByTagName("tr"); row = Math.min(Math.max(row, 0), rows.length-1); container.scrollTop = rows[row].offsetTop; }