开发者

how to display scrollbars on page load using javascript?

Is there a way to display the vertical scrollba开发者_开发技巧r 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 that height (or one that's smaller) with overflow: hidden. Once the new element has been successfully added, the overflow can be re-set to overflow: auto; (or overflow: scroll;).


Or you can set position to fixed on elements animated at begin to avoid scrollbars...

Can you create a jsfiddle.net with a little example of your code ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜