js 层随着滚动条上下移动
生活随笔
收集整理的這篇文章主要介紹了
js 层随着滚动条上下移动
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
var tips;
var theTop = 10; /*這是默認(rèn)高度,越大越往下*/
var old = theTop;
function moveTips() {
????var tt = 0;
????if (window.innerHeight) {
????????pos = window.pageYOffset
????} else if (document.documentElement && document.documentElement.scrollTop) {
????????pos = document.documentElement.scrollTop
????} else if (document.body) {
????????pos = document.body.scrollTop;
????}
????pos = pos - tips.offsetTop + theTop;
????pos=tips.offsetTop+pos/10;
????if (pos < theTop) pos = theTop;
????if (pos != old) {
????????tips.style.top = pos+"px";
????????tt = 0;
????}
????old = pos;
????setTimeout(moveTips,tt);
}
onload = function initFloatTips() {
????tips = document.getElementById('clockDiv');
????moveTips();
};
var theTop = 10; /*這是默認(rèn)高度,越大越往下*/
var old = theTop;
function moveTips() {
????var tt = 0;
????if (window.innerHeight) {
????????pos = window.pageYOffset
????} else if (document.documentElement && document.documentElement.scrollTop) {
????????pos = document.documentElement.scrollTop
????} else if (document.body) {
????????pos = document.body.scrollTop;
????}
????pos = pos - tips.offsetTop + theTop;
????pos=tips.offsetTop+pos/10;
????if (pos < theTop) pos = theTop;
????if (pos != old) {
????????tips.style.top = pos+"px";
????????tt = 0;
????}
????old = pos;
????setTimeout(moveTips,tt);
}
onload = function initFloatTips() {
????tips = document.getElementById('clockDiv');
????moveTips();
};
轉(zhuǎn)載于:https://www.cnblogs.com/xinlang/archive/2008/11/04/1326206.html
總結(jié)
以上是生活随笔為你收集整理的js 层随着滚动条上下移动的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Erlang China 大会 - CN
- 下一篇: 怎么能方便的进行数据库存储过程的版本管理