- <div id="full" style="width:50px; height:95px; position:fixed; left:50%; top:425px; margin-left:493px; z-index:100; text-align:center; cursor:pointer;">
- <a>
- <img src="图片绝对地址" border=0 alt="返回顶部">
- </a> </div><script type="text/javascript">
- var isie6 = window.XMLHttpRequest ? false : true;
- function newtoponload() {
- var c = document.getElementById("full");
- function b() {
- var a = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
- if (a > 0) {
- if (isie6) {
- c.style.display = "none";
- clearTimeout(window.show);
- window.show = setTimeout(function () {
- var d = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
- if (d > 0) {
- c.style.display = "block"; c.style.top = (400 + d) + "px" } }, 300) }
- else { c.style.display = "block" } }
- else { c.style.display = "none" } }
- if (isie6) {
- c.style.position = "absolute" }
- window.onscroll = b; b() }
- if (window.attachEvent) {
- window.attachEvent("onload", newtoponload)
- } else { window.addEventListener("load", newtoponload, false) }
- document.getElementById("full").onclick = function () { window.scrollTo(0, 0) };
- </script>
返回顶部按钮实现
最新推荐文章于 2022-04-28 18:30:34 发布