Is there a way to display the vertical scrollbar immediately after the page loads using javascript? I have a jquery slide toggle animation that, when activated, makes the vertical scrollbar appear because the toggle animation makes the page longer. The problem is that when the scrollbar appears, the document elements “spasm” or “shake”. If the vertical scrollbar appears before the jquery animation is activated then I won’t have the problem.
Update: overflow-y:scroll; does the trick without much compatibility issues!
Depending on your current function, you can use jQuery (or plain JavaScript) to find the current
max-height(that the element can expand to without making the page longer), and simply apply thatheight(or one that’s smaller) withoverflow: hidden. Once the new element has been successfully added, theoverflowcan be re-set tooverflow: auto;(oroverflow: scroll;).