//Finds y value of given object function findPos(obj) { var curtop = 0; if (obj.offsetParent) { do { curtop += obj.offsetTop; } while (obj = obj.offsetParent); return [curtop]; } } //Scroll to location of "matchdiv" function ScrollToMatch(){ var MatchDiv = document.getElementById('matchline'); var matchPosition = findPos(MatchDiv); var bodyHeight = document.body.offsetHeight; var scrollTo = parseInt(matchPosition) - (parseInt(bodyHeight) / 3); window.scroll(0, scrollTo); }When I step through this code on the first sample I created, where there are 198 lines and the match is around line 63, the value for scrollTo comes out negative, which is why is doesn't scroll properly. For the file you sent me, where the match is almost at the end, the calculation gives a value large enough that, if the browser is tall enough, the match shows. Ditto for my second example.