Page 1 of 1

[BBCode] Back to top with jQuery

Posted: 12 Dec 2011, 10:08
by all4phone
Title: Back to top with jQuery
Description: Smooth scrolling pages up. Useful when the post is long, or just for fun.
Author: unknown [minor changes by FTH & all4phone]

BBCode requires the jQuery library. If you don't have already this code on the board (forum), put it in a overall_header.html file, before the </ head>:

Code: Select all

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
bbcode usage:

Code: Select all

[top][/top]
HTML replacement:

Code: Select all

<script type="text/javascript">
        $(document).ready(function() {
           
            $('a[href=#top]').click(function(){
                $('html, body').animate({scrollTop:0}, 'slow');
                return false;
            });

        });
        </script>
        <a href="#top">{L_BACK_TO_TOP}</a>

Helpline:

Code: Select all

Moves smoothly to the top of forum [top][/top]
Example:

Code: Select all

[top][/top]

[BBCode] Back to top with jQuery

Posted: 12 Dec 2011, 20:28
by FTH
You can replace

Code: Select all

<a href="#top">Back to top</a>
by

Code: Select all

<a href="#top">{L_BACK_TO_TOP}</a>
;)

[BBCode] Back to top with jQuery

Posted: 12 Dec 2011, 20:55
by all4phone
FTH wrote:You can replace

Code: Select all
<a href="#top">Back to top</a>



by

Code: Select all
<a href="#top">{L_BACK_TO_TOP}</a>



;)
Thanks pol, first post updated ;)