Back to Top is a button once clicked it will navigate the user to the top of the page or post. It is basically used for smooth scrolling, users donot have to use using scroll bars instead they can use this button to reach to top in no time. Those bloggers who wishes to write a long post or if you have a video blog where you post lots of images in the single post back to the top of the post button is very helpful for you. Back to Top button not only saves the time of your visitor, but it also adds an enjoyment factor to your blog. In today's tutorial I will show you How to Add Back to Top Button in Blogger Bog.
How to Add Back to Top in Blogger:
Login to your Blogger account and select the blog on which you would like to place back to top Button. Now, go to Layout section >> Add a Gadget >> HTML/Java Script and paste the following code and starts customizing this buttton:
<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.bestbloggertricks.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="URL Goes Here" />', //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>
Recommended: How To Add Custom Favicon To Your Blogger Blog
Customization:
You can choose any image for your Back to Top button, here I have gave some buttons but you can use your own too if you want. Place any of the URL you like in the above code, replace “URL Goes Here” with any of your choosen URL from below and click Save.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVsiTrRUVagJp85CGnjqyQ_qM0jzkhlcGhckQHve8d_KiiX-OoShPUjC_udqhNGPK2KVc4HWgEmcuQnzkFXiigmPB5q6dITDARh0Gl-YIlPE5jdYAAlQu4iasrK1cQSMyyMe1ca8FHsIQ/s1600/back-to-top-button-for-blogger1.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAF7AQjpZNAuspMSmbiXYMraVzKfYoAUkF6YkcqVgDgbKD_XCCGlwEkfbCirfhlKvcD3ZrQMYIuOHMZ_LhFT59becrvhntFSaXt1-gFU_1gOYN6GGin-69dyWWu1AHyKCBE9_kryFKGUM/s1600/back-to-top-button-for-blogger2.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9yzBgQgcNT_0uJ1Bq2-Xxz22b_I4oj3UgX97EC3RijNQJgOkQyBE9gH3YSgGnHroWo3CZjtvTCQl-RLw1CFRJds3PpHTtoe_UUFtiTascDcxt7gD_gZxi-UWQNaVmQOIv3RTE6c_Efq4/s1600/back-to-top-button-for-blogger3.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi77bMHYVvikQ4YCbz9ndL5PEoQA8pLn9_M_fklj3MQ8kWsn9DTe5XUeAiEx44byvTBDc53Jh3R67JMxZpA-QOimj-yIo5Yp8AZihmWhYfR-QGrVeVe3Kg62p6qtZlsa0H7mlymWkUQcnw/s1600/back-to-top-button-for-blogger4.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHqo9n63_OiKS-BmKscwMatOQZyo-UhZzZk7GFxgRJvq5sOqJtvIv3DJdr9OLtmQ4CGDOH-sildzWMlReP6KD8-cPRCvl774P3AaTKtKx7MDDTgNmyNSLSTYx8ACJWZUr21uCnuVDXDCE/s1600/back-to-top-button-for-blogger5.jpg
I hope this article of mine has helped you in implementing back to top of the post button in blogger bogs, do write to us in a comment how do you liked it and if you have any problem in implanting in your blogger blog.
0 comments:
Post a Comment