Back to Top adalah widget yang bisa mengarahkan kita kembali ke atas hanya dengan satu klik tanpa harus men-scroll ke atas. Widget back to top ini juga Fdt pakai di blog ini, letaknya di kanan bawah layar anda.
Kali ini saya akan membagikan kode widget back to top ala template Google SEO v2
Widget Back to Top:
#1. Tata Letak -> Add Widget
#2. Judul Kosongkan!
#3.
Dan copy-paste kode dibawah
<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="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgs1yo_ygBdlSAxuAU4gkzvYRydq1trkku9513ip7sZpV7zX6KTl1SOiTYHLDcvXNEwPf3FsJFamDwtAvMFjThd0R-EyfhhyCq9fv6iWarmRQdgJ3jXBPy2WEmmNrdr2YvTabT1tAvnNVZk/s1600/back+to+top+button+(1).gif"
/>', //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)
Sekian dari saya Semoga bermanfaat!!