<p>What I want to do is scroll down the window when I expand elements in my page. </p>

<p>The effect I am trying to achieve is like the Stack Overflow comments. If it expands beyond the page, it scrolls down to fit all the comments in the window.</p>

<p>What is the best way of doing this?</p>

<p>Edit: I am using JQuery.</p>

If you have the advantage of using Prototype, you can use
```
$(element).scrollTo()
```
.
Otherwise, the general idea is to calculate the cumulative offset of the element, then set
```
window.scrollTop
```
(and
```
window.scrollLeft
```
) accordingly.