开发者

How to auto-scroll when the page gets too long?

I have a simple website, but I have a jquery function when a button is clicked, a l开发者_如何学Cist slides down. But I would have to scroll to see the list. How can I have it auto-scroll down when the page gets to long?


Depending the nature of your custom scroll button, perhaps you could implement it as an anchor link which jumps the page to just above the pane it scrolls?

<a class="my-scroller" href="#scrollPane">Scroll Down</a>
<div id="scrollPane">
</div>

If you are unable to use an <a href="" /> as your scroll button, you could instead have the click handler for your scroll button also change the page's location.hash value to the ID of your scroll pane.

$(".my-scroller").click(function() {
    location.hash = "#scrollPane";
    // scrolling code
});


There's an automatic left-to-right scrolling plug-in here: http://plugins.jquery.com/project/SmoothDivScroll


This jQuery plugin can be of some use for you: http://plugins.jquery.com/project/ScrollTo


Let me tell you the best way to auto-scroll a page.

When you visit a microsoft website and when there is an autoscroll it doesn't use any javascript. The way I am going to tell you is the easiest way in the world to autoscroll a page. Pure HTML.

See the code:

<a href="#thisdiv">Click to scroll</a>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<h1 id="thisdiv">HEllo to the scroll page</h1>

Thank you. I hope this would have clarified your doubt. :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜