[BBCode] Back to top with jQuery

Mods, snippets and styles postet and supported by the users
Forum rules
As the forum title says this is for User Contributions
Post a support request in this forum and you will be banned!
Locked
User avatar
all4phone
BBCoder IV
BBCoder IV
Posts: 150
Joined: 11 Feb 2011, 13:50
BBCodes: 28
Favourite BBCode: Random text signature
Favourite MOD: BBCode Strikethrough MOD
Location: Poland
Contact:

[BBCode] Back to top with jQuery

Post 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]
Last edited by all4phone on 12 Dec 2011, 20:54, edited 1 time in total.
User avatar
FTH
BBCoder III
BBCoder III
Posts: 124
Joined: 25 Nov 2011, 23:28
BBCodes: 10
Contact:

[BBCode] Back to top with jQuery

Post 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>
;)
User avatar
all4phone
BBCoder IV
BBCoder IV
Posts: 150
Joined: 11 Feb 2011, 13:50
BBCodes: 28
Favourite BBCode: Random text signature
Favourite MOD: BBCode Strikethrough MOD
Location: Poland
Contact:

[BBCode] Back to top with jQuery

Post 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 ;)
Locked