说明:让“回到顶部”按钮下方实时显示当前页面进度百分比

仅适用于handsome主题

修改步骤

  1. 打开主题设置界面
  2. 进入开发者设置 - 自定义JavaScript
  3. 将以下代码复制进去即可
$(window).scroll(function(){
var totalH = document.body.scrollHeight || document.documentElement.scrollHeight
var clientH = window.innerHeight || document.documentElement.clientHeight
var validH = totalH - clientH
var scrollH = document.body.scrollTop || document.documentElement.scrollTop
var result = (scrollH/validH*100).toFixed(0);
var d = document.getElementById('goToTop');
d.innerHTML = "<i class=\"fontello fontello-chevron-circle-up\" aria-hidden=\"true\"></i>"+"<br>"+result+"%";
})

效果图

修改前:
修改后:



- 美国低价服务器,G口带宽,稳定不丢包 -

Last modification:March 5th, 2019 at 03:17 pm
If you think my article is useful to you, please feel free to appreciate