Cara memasang back to top di blog



Cara Memasang Back to Top di Blog Blogspot
CB baru saja memasang tombol "Back to Top" di Blog ini. Anda bisa lihat di kanan bawah layar monitor Anda. 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

1. Pastikan di template blog Anda sudah ada kode jquery, yaitu kode seperti ini:

<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/AVvXsEhu_yALhPYLYtJarILY8yoqLb1vED9tYUUrlqep8IPaBUU5gHztXfKcMThlPqafsnDgiWeaZN808pYvQ3sA_KZzoJXAk6nXsALf9iQxvC1d4ZLfL7y8eXmy6Tyjz6HqsC8X2vkGH1KnC4M/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.
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimGF5eOZ2wY4Bq3qnQRa0kSX-_-AG2qXd7LpYvj1mOYiqKudE_DN6d6CCnjI7crbbcRQx9hquMDvzJY5QQ4KRSbP_OqkbecFxClerflJrvxK7S8x3qCr1B1nQIeOrQQMtp-vsZGmNTEps/s1600/back+to+top.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-vxi7iaU77iRuRQM8XRycJGDklH14zH9o4HhmZXDfHwa5dwCZiiDbYZxuyyZxqBhWbsmfkOyigQPpAJqn7VjQQJrgF6pXJb38hRGU_UApum82C7Gs90GfbA3nEAcoq4CI9HhwjvhyMIc/s1600/back+to+top.png 
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigS9K1ohH-gOazgJt1c4V3QQK1eyg0RCXEqgDTXMCoLY6HV9LPOhpZ3LQMB_oh_1slPkngWaXWxcYBP-E38BKb6wBI3shoRhHe6HmKLZHyuMtHHppOZg0EOmDcNYMI81U4GLddSVs0jis/s1600/back+to+top.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqLyEE2Z0FJbvpwtDSb3FeD36Ued8WYfwMlHwRqzawii8Tr6OyKYsaIQ-moF-CpGWatoypkk9zCbJWehivFTdGhpSGhV8Fy_lEdMHJwFIYpRUbPdCIyWS1a3vsfp66HoAAOTYiZ0Jg3_o/s1600/back+to+top.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5DFmWiNcT6If5Hmb_ydFcfEaEfVTLcT0dFxrxsOlTBV-8o-zhNC_xr0tlQdGit3vMQZUkFPB-m7dSF92rvXPmc6CJP6QnzOY7Zb5XN5idhKWCiffI0IqOcty6OsCXHSk0TW5VrdDuYRU/s1600/back+to+top+button.gif 
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7LDRn4vsafPdnhkrCUkyxn2HyuAfbLqrlmIMj8gDKTuH9WVf-5DlRrElIzO-5QUB4Uo2WN3qiWXEmHpF3nSjwbaJM9Zll-JxurDJj5JD6wQ1yu44cPjRNiW7_or95qrryuUbE-cR2SQg/s1600/back+to+top+button.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8NkA_rn0A_1KrFCIHr_uKTXyeCGw_aOmVVQgclpX26iBvFdBdzE5-7Zy_axWmmbE_YTJUAiOSdn2Zw0fl-q7qB3WskotP0SDVMVexaY3wqpCyVL4Ok80cd2HzQLOxezOhR8ZDxv7ZjVE/s1600/back+to+top+button.gif 
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPr6su_tHHVUYzAuhor8nqkUsoXTpGbkY8Di2j58z5ytPC77rQVDJHOyNDw_T_VzpuPv26VbP6cjaCZOzRWD6RHpJrUxtu41-e6_f4JnbOxVP-b5Fi2q82jLVNAlb_BYNUm8WBWxErVTg/s1600/back+to+top+button.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu_yALhPYLYtJarILY8yoqLb1vED9tYUUrlqep8IPaBUU5gHztXfKcMThlPqafsnDgiWeaZN808pYvQ3sA_KZzoJXAk6nXsALf9iQxvC1d4ZLfL7y8eXmy6Tyjz6HqsC8X2vkGH1KnC4M/s1600/back+to+top.png 
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC0WWNxp3wJKp_VOaBkdh2-cndj1F7MR8BzkNFddbxi2ubFJlK7ijjZSoPUC6p6DWNYYtybpnIR1y5-N_VXip-ZC-vvdrn9rIb0UiA1588pvLNQfuH_i7eW7JUgXNj57czz8J1YLf7nAA/s1600/Back-To-Top.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvUkW-78mlJQ30xSPyzkG5VQD2uKzDK4jWRJdmHH8NzsQhV9goXKgPrAyngT3FcUe6iZsZVEZZMT11DKMOUuMqIgtxAkxmjmdt1ALdKNE5V-79zd-HaqDW5zuLTKzDUBtci3FpBDnmnLk/s1600/back-to-top-button.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8wka9Xa7V_jdCYXv1U7b9Fg-Zpjs-xm9SM-fFMD9h2IPztVKAf-VBgkRqOM2afKegTaz_jRihR1s8-p4MjiAy0t3LidvI0aLps7ojudFZnVMT2KIkxnX6_4pj5Wu6inRBYBhH9fWTbc8/s1600/back-to-top-button.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzj6W8QqTcJ-vfexLz4yqkVgqyfr18XPGQk6CkHITH9NTih9_2kJO50dXbQus0IwIMy60PiYZPudep9p-EQEyPgIE26uSvPIeOLWw3AF5lqDRcaqtKaSvxsms1rpfVnklmQFjFxpwLQm0/s1600/back-to-top-button.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh38WMV1CS0CFR87AokXa_QfYPlUERRoBclh4odUxgsFtnA6PFR1bRrmGL0XtxNuK6pCa7XIhGVBawaGaN9OxpcnaZKgGSyA1AixRTy6EUZeHIyDaBZgIBUik8Bwa9nrrhMWiDAcZdrifM/s1600/Back-To-Top.png
 Back to Top di Blog
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSTQELMfVahNitit7kCfQHdQ4ZFgk4cRNbGcUrLhjgtkOQr_oMukP3qE_OkN5Xs6v1sg06A-iaTLxnqni4P6UfDf29-tVcOPvf7YxUWGL_MrIITLXBm56-oajq9m3KqxOUNKHonI9Wy4U/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>

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!


EmoticonEmoticon