Cara memasang Back to Top seperti ini sangat mudah.
Tombol "Back to Top" memudahkan user atau pengunjung kembali ke bagian atas blog, dalam satu klik, tanpa harus men-scroll mousenya atau "mengusap-usap" jarinya di "touch pad" atau layar SmartPhone-nya.
CB merasa butuh memasang tombol "kembali ke atas" ini karena kadang/sering harus membuka postingan dengan komentar yang banyak, sehingga "turun banget" dan harus bersusah-payah "scroll" ke bagian atas.
Nah, dengan adanya tombol "Back to Top" ini, CB tinggl "klik" dan tampilan bagian atas blog akan tersaji secara otomatis.
Cara Memasang Back to Top Terbaik untuk Blog
Berikut ini cara pasang back to top di blogger:
1. Tema > Edit HTML
2. Copas kode berikut ini di atas kode ]]></b:skin>
2. Copas kode berikut ini di atas kode ]]></b:skin>
#back-to-top {background: #E73037;color: #ffffff;padding: 8px 10px; font-size:24px}
.back-to-top {position:fixed!important;position:absolute;bottom:20px;right:20px;z-index:999}
3. Copas kode berikut ini di atas kode </head>
<link href='//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' rel='stylesheet'/>
4. Copas kode JavaScript Back to Top Terbaik untuk Blog ini di atas kode </body>
5. Simpan Template!
1. Pastikan di template blog Anda sudah ada kode jquery, yaitu kode seperti ini:
Atau seperti ini:
Kalau belum ada, lakukan langkah ini:
- Template > Edit HTML
- Cari (CTRL+F) kode </head>
- COPY salah satu kode tersebut dan PASTE di atas kode </head> tadi.
- Save!
2. Klik "Layout" (Tata Letak)
3. Klik "Add Gadget" di Sidebar
4. Pilih "Javascript/HTML"
5. Copy dan Paste kode berikut ini:
Kode yang berwarna merah adalah image "Back to Top". Anda bisa menggantinya dengan gambar lain sesuai dengan selera Anda, juga sesuai dengan background blog Anda.
<div class='back-to-top'>
<a href='#' id='back-to-top' title='back to top'>
<i class='fa fa-chevron-up'/>
</a></div>
<script>
$(window).scroll(function() {
if($(this).scrollTop() > 200) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
});
$('#back-to-top').hide().click(function() {
$('html, body').animate({scrollTop:0}, 1000);
return false;
});
</script>
5. Simpan Template!
Cara Memasang Back to Top Lainnya
Berikut ini alternatif pemasangan back to top tanpa menggunakan font awesome.
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'/>
Atau seperti ini:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
Kalau belum ada, lakukan langkah ini:
- Template > Edit HTML
- Cari (CTRL+F) kode </head>
- COPY salah satu kode tersebut dan PASTE di atas kode </head> tadi.
- Save!
2. Klik "Layout" (Tata Letak)
3. Klik "Add Gadget" di Sidebar
4. Pilih "Javascript/HTML"
5. Copy dan Paste kode berikut ini:
<style>
.mbw-back-to-top {
position: fixed;
bottom: 2em;
right: 10px;
text-decoration: none;
padding: 1em;
display: none;
cursor:pointer;
}
</style>
<img class="mbw-back-to-top" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaW3VBC_WTMO7UtXg5hEkRo6PfO14DS0jK8Qp4q8lGfHOyM7N3v3eRyXqXZF3T7GJqDDQ_pc0Bpm0FDO_3BHkMDwAoRpE7l7xQjted0JaRmL0KzJTwnJu184tBC76AeTFjXHQ9waMa7bo/s1600/back+to+top.png" />
<script type="text/javascript">
/*****mybloggersworld.com***/
jQuery(document).ready(function() {
var offset = 220;
var duration = 500;
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > offset) {
jQuery('.mbw-back-to-top').fadeIn(duration);
} else { //www.mybloggersworld.com
jQuery('.mbw-back-to-top').fadeOut(duration);
}
});
jQuery('.mbw-back-to-top').click(function(event) {
event.preventDefault();
jQuery('html, body').animate({scrollTop: 0}, duration);
return false;
})
});
</script>
.mbw-back-to-top {
position: fixed;
bottom: 2em;
right: 10px;
text-decoration: none;
padding: 1em;
display: none;
cursor:pointer;
}
</style>
<img class="mbw-back-to-top" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaW3VBC_WTMO7UtXg5hEkRo6PfO14DS0jK8Qp4q8lGfHOyM7N3v3eRyXqXZF3T7GJqDDQ_pc0Bpm0FDO_3BHkMDwAoRpE7l7xQjted0JaRmL0KzJTwnJu184tBC76AeTFjXHQ9waMa7bo/s1600/back+to+top.png" />
<script type="text/javascript">
/*****mybloggersworld.com***/
jQuery(document).ready(function() {
var offset = 220;
var duration = 500;
jQuery(window).scroll(function() {
if (jQuery(this).scrollTop() > offset) {
jQuery('.mbw-back-to-top').fadeIn(duration);
} else { //www.mybloggersworld.com
jQuery('.mbw-back-to-top').fadeOut(duration);
}
});
jQuery('.mbw-back-to-top').click(function(event) {
event.preventDefault();
jQuery('html, body').animate({scrollTop: 0}, duration);
return false;
})
});
</script>
Kode yang berwarna merah adalah image "Back to Top". Anda bisa menggantinya dengan gambar lain sesuai dengan selera Anda, juga sesuai dengan background blog Anda.
Koleksi Gambar Tombol Back to Top untuk Blog
Ini pilihan gambar/tombol "Back to Top" dan URL-nya yang bisa Anda gunakan. Copas link URL-nya ke bagian yang berwarna merah dalam kode di atas tadi.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLtFlYL7myTaFZR68CS7x-Cdihk2YIvyCx5JiwdY8ciBfr_dpT7jeLPZ_SOrg_x2fu_RwdxSqLyFMONGy6BJ_npmFgEOUI34BboXDgVtqeCrDhNfUTbZBZoE2WJm59Rm0BRGlQZ6Ba9Z0/s1600/back+to+top.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipy3NwkuDdjHsP-jZC90RBFr7zg-DJy5IbAHpHbLSkHB3r1RzkRtePSox_M0yn04L4svDNu6eFzt_96MCINtjy6h2Jd0hQIZ1SG-fz9Sb44VYMK3HuuFf6aK_YsGO3mgCvF7xiSRpgRfU/s1600/back+to+top.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1Bx0ft8bklA3LvG9bI9LpO3eEXlDkXsvum_BGFI9JpHzbCsfBucoZL3U1WzK0A1SZsWWkKkd_xUOm5qa1ugrUIqS7Yp7QVgt6ve7TWf_53m7hbsUgnnfRyMG-n3PmoR2mSy7cOVc_5qs/s1600/back+to+top.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguizLOtVuXzkaFy0SKLo1-e9Tqip3CuPXV9XRF49JTAQ7lXGDRIlaqu4C_O20B8mzGcGVIKLTICj7oU5SBah6wFM4C1JG6q8sb-6cS-UE6Y50qrJ8g4Lgs9Bvwp0dbpMQtoh4UEd86UD8/s1600/back+to+top.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc3AqrCkiXHU-9eAe7cMNU47FLQtxi6U9Xv6C-pxSFixVsbUGzRD6HSHd32N_ARFBGDh-uD7yyDx_6fEiLBU-wGfLX45u0jPTlAhS913CcmeRYna-inpU8TAJjlqdjDiwEoz9tABFzlF8/s1600/back+to+top+button.gif
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiITUTPmKj2_qJTR9L-kZIgdBjibcU2YCeqXwGxgfc4U6i6cT2hgKYTQRABcm9TKGqCaLc9G1Oh8oS6hJrwmAgAwDhAUip5SyZj2yGbcQsrn8tCNsz5h5uPiwEW20VWRYxcostVM5Ngg2s/s1600/back+to+top+button.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVt3ch08RYS6zltBprjSaXF6yysfLBLOmvE1cuwGe3QgWuCv1BGmWyO4mohKA_sICp_SV9OFwX-_3cPmAFrB23fGgrzPLIhk6rGid8oS7ZOGJ5uvTASEQbW1MkNUQk5XwsEt6mXcoj7cM/s1600/back+to+top+button.gif
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiGuxgeKrahmzvjqqkccPjXyEXp8F08NtvUp289tKq64sM1ntg1TkPtOM9KjO_1ee2vxbBdRHrmo7pUoeEabq8rTRnfEBhYikSC-OBIUgw9OcI_tdBCVyzR8yxXKMJFKkh8Mifvd4747A/s1600/back+to+top+button.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaW3VBC_WTMO7UtXg5hEkRo6PfO14DS0jK8Qp4q8lGfHOyM7N3v3eRyXqXZF3T7GJqDDQ_pc0Bpm0FDO_3BHkMDwAoRpE7l7xQjted0JaRmL0KzJTwnJu184tBC76AeTFjXHQ9waMa7bo/s1600/back+to+top.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrB8UocqaDS1XHo5iq59rVxQZxYCERYvs2EnPh7baXbJwq9475U6wIoShpD4Se1AwzEI30c3VkiStS1rawZkYKmUgoGq2XMUUZeB6UK0alZGKO8TZTiHE6ojrZgulYqekSMOKNsL6Wfh0/s1600/Back-To-Top.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJLBx2zaO38U1hEeAl7AH9WTJFTD2d4W1Uj7k40EpI1nuf35gi9ipWb5Dm5oQJ6G03j-UfrIu825ZITnu786dhnXzhey6U87rcfG8unhV86KJxfsY8wTld6t3lp5HB0n4gRytxyC16fpQ/s1600/back-to-top-button.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB1kXDUav3Jm6waNKf3uu2-wVvkZ1Zh5hcK-Mu6ZzedwCwfMFoVVT4IOiIRL1b7ZlkE21E0cWp76oaKGK9ju1VQcZILY3xMnVZu0aJ_Q5gkgWoTSYVBKvHGRtElt33Il_zVdS8ZGZjpnM/s1600/back-to-top-button.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfxtr68hfifZ9dhdWlr8WDbxhHHI4nrv23FaEfynLYmd6wFjqaMyyXgIAwBPg5DZMZGp3n2L4Z5X2QK7t69skf7Dis1bwOABddXL8lh4D9TNYIkfb1C8k7CDYTYzZhn_GrSsHuwp_84rE/s1600/back-to-top-button.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIrfhNu5gw_QQKvJuFeGVX1w_phvcIP8E4F4HzByHJSRSa1AENP3r4G6FmNCtUo08e-pNHJMWEIJAMmCGcwUNAGH-NT12hqOxOy8EZHMML8yk3jk2p0n_q5AyVlTzjjW5GAZPpie4AdHA/s1600/Back-To-Top.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaw1uxgxHLvLahz5mCjXCBiKvqcVKZYcju7G_Sy77kMVjILSuqAsyR2i_Hx_mYCdlIiJAjeRd9b_9vqcj-thFvm8jSX1A1rMRxNX7ejpSp3U2ZkS7XHCyCh_91Px9q1txB1OIVCtydzB0/s1600/back_to_top_button.png
Alternatif Cara Memasang Back to Top
Jika cara di atas tidak berhasil, coba lakukan langkah berikut ini.1. Layout
2. Add Gadget
3. HLML/Javascript
4. COPAS kode berikut ini dan Save!
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" >
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 Gambar Back To Top" />', //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>
<script type="text/javascript" >
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 Gambar Back To Top" />', //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>
Itu dia cara membuat atau memasang tombol Back to Top di blog blogspot untuk kenyamanan dan kemudahan pengunjung, juga kemudahan kita sendiri sebagai admin blognya.
Good Luck and Happy Blogging! (https://terjeru.blogspot.com).