回到顶部
<div id="FloatDIV" style="position: absolute; top: 0px; z-index: 9999; background: #fff000; cursor: pointer;" onclick="window.scrollTo(0,0);">回到顶部</div>
<script type="text/javascript">// <![CDATA[
var MarginLeft = 10; //浮动层离浏览器右侧的距离
var MarginTop = document.body.clientHeight - 80; //浮动层离浏览器顶部的距离(浏览器高度-div高度)
var Width = 25; //浮动层宽度
var Heigth= 80; //浮动层高度 //设置浮动层宽、高
function Set()
{
document.getElementById("FloatDIV").style.width = Width + 'px';
document.getElementById("FloatDIV").style.height = Heigth + 'px';
} //实时设置浮动层的位置
function Move()
{
var b_top = window.pageYOffset
|| document.documentElement.scrollTop
|| document.body.scrollTop
|| 0;
var b_width= document.body.clientWidth;
document.getElementById("FloatDIV").style.top = b_top + MarginTop + 'px';
document.getElementById("FloatDIV").style.left = b_width - Width - MarginLeft + 'px';
setTimeout("Move();",100);
} Set();
Move();
// ]]></script>

参考:博客园

最新文章

  1. OpenGL、Open Inventor、WebGL、Three.js、ARToolkit、JSARToolkit
  2. php 二分查找
  3. Codevs No.1553 互斥的数
  4. 转:艾瑞咨询2016 IM云的发展趋势
  5. php类 静态变量赋值 static $name=&quot;abc&quot;
  6. Codeforces Round #326 div2
  7. js识别终端类型
  8. 在MAC上安装GitHub DeskTop
  9. 一个三维点类Gpoint3的实现
  10. web api 安全设计(1)
  11. Kubenetes---Service--实践
  12. Machine Learning 神器 - sklearn
  13. apache利用http_referer进行防盗链
  14. Windows7 VS2015 下编译 Python3.6.6
  15. opencv学习笔记(五)
  16. 关于Android Camera2 API 的自动对焦的坑
  17. angular4-自定义组件
  18. 【转载记录】Accessing Device Drivers from C#
  19. _bstr_t可接受多字节、UNICODE字符串,方便用以字符集转换
  20. hashMap 和 linkedHashMap 的区别和联系

热门文章

  1. Unity VFX踩坑
  2. NO15 第一关课后考试
  3. Golang的环境安装
  4. 138-PHP static后期静态绑定(一)
  5. 115-PHP实例化和不实例化输出类常量
  6. python 第一节 脚本 import from reload exec
  7. sql拆分列 时间拆分 日、月、年
  8. 2 ~ express ~ 模板引擎的配置与使用
  9. iOS 保存图片(视频)到相册
  10. 实验吧Web-中-简单的sql注入之2