- Pertama masuk ke Blogger lalu pilih Layout terus Add a Gadget dan tambahin HTML/JavaScript gan. Terus tinggal loe pastein kode di bawah ini di kotak kosongnya.
<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>
- Kalo udah di pastein sekarang tinggal di ganti URL Gambar Back To Top sama url gambar punya loe gan lalu di Save. Coba sekarang buka blog loe pasti udah ada tombol back to topnya gan.
Kalo loe gak punya gambar tombolnya ni gw sediain gan, ada yang animasi sama standar tinggal dipilih aja.
Animasi :
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnCUMlUAeTDtybY-Q4sidkOEGDWGKfKdDNPyVwYgfgIA5rfLFFeefrCcqZlEn_3W4EE2auL0MWccaumMlNQtlA_9Dmktik8Ui3fvVVlWISlCutfbmYfyW8g7dCAF55MTMLL2BYdaJmt4yt/s1600/back+to+top10.gif
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirhkPqGfy7dR4jgTnDG4eSQN8D-iQJ9zODyISRMLjRQaII3lxBiFMCQTy_KcwppfOwTP6Y_iaNMKrFqKOl6-ijI4Lxx_OWaNQ7dLUKHBQXWdBYswUuOUwRleFo5kci2KS1GmejKnkjHCmy/s1600/back+to+top4.gif
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS4rbyU5zgC3ddK5Hj2qaWG-UyyUUzRrGmYQ7XYnk28x8L2T2SWeYt3IBsH2A_Xx3W9shIYrN7a5iRkSS0nB_cMgwaqVdi1dFANr8ewweKprUGeaZcgqXvLlYOI87uMzXpFTki1i6EJKxq/s1600/back+to+top7.gif
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijs-ZxkCRaS7ZyVGVXjbtp9xcvLTKKW2e0uGGbKEiySs8T2ypt-zDWzVpuVIL6RBGlZ8pj1uXG32uFEFuyVX4SrY6T8PCwr1lcIezUryctS-TazSlCTOyckBlE13DZKP38032E-jt9NjrA/s1600/back+to+top9.gif
Standar
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuv1YkUNRGGPEbolUlccaQ7KbX1ordITrzUbjCrFe0xag4ngBAMzMGjxgBW7iHiLQ2hCL6LxTzteRIAqel7Lzi4aJSxBoxTPvn1Y7yr1dYUP_UmhSzSYHhMXLKrK2XSi6Iaog-Nd3Gk7Hq/s1600/back+to+top13.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG3gB3rkp1KnaLWoTkyWyfnTK4KS8uIl5vFa5fez7na-zBFS6iSidzEubKRUdlLVWHZL2L7s9Qyh5sPhGRWaADHWgYa3E8Q6d-IIZ4qMpOXA8m2jMSqzQFP4yhk-0kwG7JvKX7e5HksrY3/s1600/back+to+top14.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0VetXE9H0dD7CmBu4nznaRu9xhr4MJs_kuKtWmVGYj-SjoXKB74kXAbxsu6Q9_XIjIr2PcMfhP5I73aTz6zpR9FZTMIzN_h05RDilOf-qPoTA4Hz7K2-5X-YuNglkwlfLbxkRrIxkHi8-/s1600/back+to+top15.png
Beres gan, gampang kan cara membuat tombol back to top di blognya. Ow ya kalo loe mau rubah kecepatan scrollnya bisa di edit aja scrollduration, semakin besar angkanya semakin lambat gerakan ke atasnya gan
0 komentar:
Post a Comment