September 4, 2011

Widgets

Smooth Scrolling "Back To Top" Button for Blogger


scrolling back to top buttonFinally yet another exciting trick to create a smooth scroll to top button for BlogSpot blogs. We designed and released many buttons and tutorials on back to top/bottom buttons but they were all static and had no fade out effects and smooth scroll effects. Luckily we just discovered a cool jquery script that does all the work. A back to top button is crucial for a blog or site because visitors enjoy easy site navigation so this button will provide them with this ease. We have kept the installation process a one step process. Please see this button in action towards the bottom right corner of this blog.

The best thing about this button is that it appears only when the user scrolls down the page and disappears as he scrolls up.

Add Scroll to Top button to Blogspot

  1. Go To Blogger > Design
  2. Choose HTML/JavaScript widget
  3. Paste the following code inside it

 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" >

/***********************************************
* Scroll To Top Control script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Modified by www.MyBloggerTricks.com
* This notice MUST stay intact for legal use
* Visit Project Page at http://www.dynamicdrive.com for full source code
***********************************************/

var scrolltotop={
    //startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
    //scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
    setting: {startline:100, scrollto: 0, scrollduration:1000, fadeduration:[500, 100]},
    controlHTML: '<img src="IMAGE LINK" />', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
    controlattrs: {offsetx:5, offsety:5}, //offset of control relative to right/ bottom of window corner
    anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

    state: {isvisible:false, shouldvisible:false},

    scrollup:function(){
        if (!this.cssfixedsupport) //if control is positioned using JavaScript
            this.$control.css({opacity:0}) //hide control immediately after clicking it
        var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
        if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
            dest=jQuery('#'+dest).offset().top
        else
            dest=0
        this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
    },

    keepfixed:function(){
        var $window=jQuery(window)
        var controlx=$window.scrollLeft() + $window.width() - this.$control.width() - this.controlattrs.offsetx
        var controly=$window.scrollTop() + $window.height() - this.$control.height() - this.controlattrs.offsety
        this.$control.css({left:controlx+'px', top:controly+'px'})
    },

    togglecontrol:function(){
        var scrolltop=jQuery(window).scrollTop()
        if (!this.cssfixedsupport)
            this.keepfixed()
        this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
        if (this.state.shouldvisible && !this.state.isvisible){
            this.$control.stop().animate({opacity:1}, this.setting.fadeduration[0])
            this.state.isvisible=true
        }
        else if (this.state.shouldvisible==false && this.state.isvisible){
            this.$control.stop().animate({opacity:0}, this.setting.fadeduration[1])
            this.state.isvisible=false
        }
    },
   
    init:function(){
        jQuery(document).ready(function($){
            var mainobj=scrolltotop
            var iebrws=document.all
            mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
            mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
            mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+'</div>')
                .css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', bottom:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'pointer'})
                .attr({title:'Scroll Back to Top'})
                .click(function(){mainobj.scrollup(); return false})
                .appendTo('body')
            if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
                mainobj.$control.css({width:mainobj.$control.width()}) //IE6- seems to require an explicit width on a DIV containing text
            mainobj.togglecontrol()
            $('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
                mainobj.scrollup()
                return false
            })
            $(window).bind('scroll resize', function(e){
                mainobj.togglecontrol()
            })
        })
    }
}

scrolltotop.init()

</script>

Replace IMAGE LINK with the image link of your back to top button. You can get several beautiful free buttons from our library. Download Back to top/bottom buttons. If you want a free image link then right click the buttons below and select "Copy image location" to fetch their links:back to top

back to topscroll to topscroll to top

     4.   Save the widget and drag it near the footer or any bottom position.

      5.  View your blog to see the magic.

 

I this little trick works for all of you. If you have any questions on how to adjust the position and fade duration then please let me know. I didn't mention them for simplicity. Please do a favour by sharing it with your friends on FB and G+. Peace brothers. :)




If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you Subscribe to our regular Email Updates!

If you don't want to get yourself into Serious Technical Trouble while editing your Blog Template then just sit back and relax and let us do the Job for you at a fairly reasonable cost. Submit your order details by Clicking Here »

54 comments:

Muhd Firdaus on Sep 4, 2011, 4:32:00 AM said... #

to many code there :(

i found a more minimalist then this..

jquery
jQuery(document).ready(function($) {

$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
});
});

Muhd Firdaus on Sep 4, 2011, 4:34:00 AM said... #

@Muhd Firdaus

html
<a href="#comments" class="scroll">Scroll to comments</a>

just sharing :)

ahmed safwan on Sep 4, 2011, 6:48:00 PM said... #

please mohammed i have sent you the template please help me man please

Mohammad Mustafa Ahmedzai on Sep 5, 2011, 12:28:00 AM said... #

@Muhd
Indeed your code works too as I shared even smaller than this on this post but they don't have fade in and fade out effects along with fade duration. Further this script does not gives a quick jump but rather it takes visitors smoothly by scrolling gently to the top. Hope this makes sense now. :)

@Ahmed
I will check it tonight brother.

Areevz on Sep 7, 2011, 8:54:00 AM said... #

Bro.. I like your site, can you increase the loading speed?

Gamer on Sep 20, 2011, 1:45:00 PM said... #

Hi thnkyou very much its work for me :)
Visit my blog http://freedownloadspcgames.blogspot.com
i need backlinks :)

Inderpal on Sep 22, 2011, 5:19:00 PM said... #

Thank You Very Much :)

pursuite on Oct 1, 2011, 4:49:00 PM said... #

Sweat beaty

pursuite on Oct 1, 2011, 4:52:00 PM said... #

Chek out mine

http://hakiz99.blogspot.com/

Umesh Tarsariya on Oct 6, 2011, 11:27:00 AM said... #

WOW...........
i done it in My blog
http://sadhakparivar.blogspot.com/
thank you so much sir......../

Moltez.M on Nov 3, 2011, 8:25:00 PM said... #

Thank You, its great!
http://tudatosebredes.blogspot.com/

Matthew B on Nov 14, 2011, 4:43:00 PM said... #

Thanks for this script, been looking for a back-to-top button with easing and custom image the whole day! It works great, have a look at http://eyesontheescape.blogspot.com/

FAIZAN ALI on Nov 19, 2011, 9:05:00 PM said... #

Thanks i applyed it on my blog check it http://www.everfreetech.com/ i am from pakistan great blog

Thomas on Nov 20, 2011, 3:26:00 AM said... #

@ahmed safwan

Salaam alaikum, friend

Thanks so much for this work; it was the first page I landed on when searching for this awesome feature, as I have very long pages on my Transformers weblog, and it can be tedious to scroll back to the top manually. Thanks a bunch,

Vangelis on Nov 21, 2011, 10:03:00 PM said... #

Thanks a lot Mohammad, i've mplemented it on my blog too, cheers from Greece!
http://toxrisimo.blogspot.com/

Mutalib Attholib on Nov 25, 2011, 8:30:00 AM said... #

TQVM :) Have a good day!

John on Dec 4, 2011, 8:18:00 AM said... #

Thanks man, I used it on my blog http://www.quasarworld.blogspot.com

Yasir Utomo on Dec 7, 2011, 7:30:00 PM said... #

hi. i have try it, but it may crash with my tab javascript. i dont know what the problem. (sorry for my english by the way)

Yasir Utomo on Dec 7, 2011, 7:42:00 PM said... #

hi.. i comment again for tell you that its work for my blog. i just remove the 2 firts lines because i already have jquery script script. thanks.

Miss Lovouis on Dec 27, 2011, 1:05:00 PM said... #

The image does not appear ??
Why , can u help me ??

Thomas on Mar 3, 2012, 1:19:00 PM said... #

@Thomas

Very cool resource! I am using one for my friends article marketing blog, which he tasked me to spruce up. Had a little trouble getting the code to render correctly, so it goes out from time to time. But when it does work, it allows us to put many posts on one page. Great job!

asadakahawk on Mar 23, 2012, 4:05:00 PM said... #

Thanks a trilllion!! :D

Touchwood on Apr 15, 2012, 12:05:00 PM said... #

I want to bring it to the middle of my page...how to do that?

Cassandra Niki on Apr 16, 2012, 1:36:00 AM said... #

Thank you very much! Works perfectly!
http://blog.cassandraniki.com

sidhant on Apr 16, 2012, 1:49:00 AM said... #

awesom check out mine i did it in my blog
http://mahajancollection.blogspot.in/

shealiverobot on Apr 27, 2012, 3:15:00 AM said... #

Hello! I am in Loooove with your blog, all widgets works PERFECT, but i am having a little trouble with this one, even it works, when i place it in the right sidebar unwrapped the multitab menu and when i place it in the footer, left sidebar, below posts or anywhere else stops the slideshow, what can i do???? please help me. THANX!

TheMobiForest on May 12, 2012, 2:20:00 AM said... #

Nice trick..

www.themobiforest.com

Minimusha♥Meggymusha on Jun 1, 2012, 8:10:00 AM said... #

Thank you so much! :D

Levis Raju on Jun 2, 2012, 1:55:00 PM said... #

Thanks for giving me the code. I had made some images. Plz check this : The UP Style scroll back top buttons for blogger - http://www.netinfozblog.in/2012/06/35-up-style-scroll-back-to-top-buttons.html

Jumi on Jun 29, 2012, 11:44:00 PM said... #
This comment has been removed by the author.
DauGyung on Jul 3, 2012, 5:54:00 PM said... #

thank you so much.............
http://headerline.blogspot.com/

WakeUp Music on Jul 23, 2012, 4:04:00 AM said... #

thank you very mach ^______^

grohon on Aug 3, 2012, 3:39:00 PM said... #

Topup Bangladeshi mobile from anywhere in the world by following this site

http://www.bdtopup4u.com

its easy and reliable

Brandon Lobo on Aug 6, 2012, 11:08:00 AM said... #

Just added one to my blog <a href="http://supportiveposts.blogspot.com/" target="_blank">Supportive Posts</a> It's awesome! Thanks :D I already shared ur post on my G+ page and +1'd many of your pages. Thanks so much...

Admin on Aug 6, 2012, 8:38:00 PM said... #

The problem with this trick is that with different screen resolutions the button appears in different places. So, if your resolution is big (let's say 1920x1080) and you adjust the position of your button according to your resolution, the button may overlap your blog's content for visitors with smaller resolution (let's say 1024x768 (my resolution)). And the opposite, if you adjust the button for small resolution it will go far away from your content for visitors with higher resolutions, which doesn’t look aesthetic.

Is it possible to make a fixed button which position is determined according to the blog’s content and not the screen sides, so that it remains in the same proportions according to the blog, with the different resolutions?

Thomas on Aug 11, 2012, 2:54:00 AM said... #

This works very nicely for my Fage Greek Yogurt diet site. I thank you for taking the time to set it up in an easy to read format.

Thomas on Aug 11, 2012, 2:56:00 AM said... #

Still going strong after all these months. Alot of times I find that code i use from another site starts to mess up after half a year has passed.

Endowment

Delbert Ednave on Aug 18, 2012, 4:00:00 PM said... #
This comment has been removed by the author.
Delbert Ednave on Aug 18, 2012, 4:10:00 PM said... #
This comment has been removed by the author.
Delbert Ednave on Aug 18, 2012, 4:15:00 PM said... #

you can adjust it in these codes > controlattrs: {offsetx:5, offsety:5}

protectivegloves on Sep 29, 2012, 1:51:00 AM said... #

amr mohammed

your blog amazing
i tried to do some of your triks at my blog

i hope to visit it

http://www.protectivegloves.net

Shelly on Oct 12, 2012, 11:52:00 AM said... #

This worked beautifully! Thank you!!! :)

Renju on Nov 5, 2012, 4:53:00 PM said... #

Thanks a lot. .Works like charm on my blog too. . .
www.renju-baby.blogspot.in

mee.shell on Nov 5, 2012, 8:12:00 PM said... #

thank you so much!

http://mmeeshell.blogspot.com

依之汉 on Nov 8, 2012, 3:38:00 PM said... #

Brother, how can I change the back to top to the left side of my screen? Or any idea to explain where is the script to change its location? I really appreciate it.

Vivek on Nov 10, 2012, 4:04:00 PM said... #

thanks for the post.... I added the code on my blog
[solved] How To Find If Someone Is Using Your Facebook Account

Abhishek Gupta on Nov 13, 2012, 7:49:00 AM said... #

hello ..Mohammad Mustafa Ahmedzai bro i am back again..
there is a problem that how can i make the back to top widget same as urs that is a little bit to up and oblique..

can u provide me the code of ur back to top widget

i have also liked and followed u bro
hope u will help me and u can mail ur back to top code in abhishek_luck19@hotmail.com

regards,
abhishek

Helen B. @ Blue Eyed Beauty Blog on Nov 20, 2012, 2:34:00 AM said... #

Thank you so much for sharing this HTML code!!! I've wanted to add this feature to my blog since seeing it on Pinterest! I will be sharing this with my readers soon and will link back to here so they know where I found this wonderful code!!! THANK YOU again!!!

Helen
Blue Eyed Beauty Blog

Larissa T. on Dec 8, 2012, 8:19:00 AM said... #

Thank you!!!!! :D

palvash sheikh on Dec 10, 2012, 9:08:00 PM said... #

http://dj1sheikh.blogspot.com

crazygrape on Dec 13, 2012, 6:52:00 PM said... #

Yes this works Perfect!!!!
But I have a Problem; The Facebook recommendations bar cover half of it, Can we move the recommendation bar towards little left or this scroll to top a little top.
See me... << check Please if you don't understand me. :)

Admin on Jan 5, 2013, 12:19:00 AM said... #

Hi Mohammad
i have trouble when i'm apply this trick, my width of blog has change ... Can u help me resolve this isue?
See Me -> thanks before !

Zulqurnain jutt on Mar 9, 2013, 9:10:00 PM said... #

Salam, Nice tut and old too but i need to know if i want my back to top image in the footer as you,ve done with your blog, but its text back to top , but the main thing to notice it that it is fixed and not fade in fade out effect kindly can you give me the code or instructions ,expecting answer fast :)

H4ck3r Cracks

somu sekhar on Apr 24, 2013, 4:03:00 PM said... #

www.tollywoodpolitics.com
www.bollywoodindiaboxoffice.com

telugu

Click Here To add Comment

Confused? Feel free to ask

Your feedback is always appreciated. We will try to reply to your queries as soon as time allows.

Note:
1. To add HTML CODE in comments then please use our HTML Encoder
2. You can always Test the tutorial on our HTML Editor
3. No cheesy/spam Comments tolerated Spam comments will be deleted immediately upon our review.

Regards,
Mohammad

Support Us

If our Tutorials have helped you a little, then kindly spread our voice using the badge below:-

or try a Beautiful Banner


Widgets

 
  • MBT Icons and buttons

    Icons and Buttons

    Our resources have been successfully downloaded over 10K times and found almost every where. Get yours!

  • choosing webhost for a blog

    Why HostGator?

    Learn Why we chose HostGator as our Web Host and find discount coupons to kick start your blog today!

  • SEO Settings for blogger

    ALL IN ONE SEO PACK 2012

    Learn every single SEO tip that will boost your blog's ranking and organic traffic. We got them all!

  • Blogger widgets and plugins

    Visit MBT's Blogger LAB

    Why not take a tour of all great Blogger widgets published so far? You Name it we have it!

  • become a six figure blogger!

    Become a SIX FIGURE BLOGGER

    Learn what it takes to become a successful entrepreneur and build a living online!

About The Author

Hi! I am Mohammad, a certified SEO Consultant, Pro Blogger, Computer Engineer and an addicted Web Developer. Read More..

Recipes

SEO Affiliate Marketing Social Media

Make Money Online Web hosting

Blogging Tips Web Designing

Plugins and Widgets Blogging Ethics

Recent Comments

Popular Series

Powered by:

My Blogger Tricks © 2013. All Rights Reserved | Contact |