<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#div1 {width:100px; height:150px; background:red; position:absolute; right:0; bottom:0;}
</style>
<script> window.onscroll=function()
{
var oDiv=document.getElementById('div1'); var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
//alert(document.documentElement.clientHeight);
//oDiv.style.top=(document.documentElement.clientHeight-oDiv.offsetHeight)/2+scrollTop+'px';
//alert(document.documentElement.clientHeight);
//document.title=oDiv.offsetHeight;
//alert(oDiv.offsetHeight);
//alert(document.documentElement.scrollTop);
//alert(scrollTop);
//alert(document.documentElement.clientHeight-oDiv.offsetHeight+scrollTop);
startMove(parseInt((document.documentElement.clientHeight-oDiv.offsetHeight)/2)+scrollTop);
} var timer=null;
function startMove(iTarget)
{
var oDiv=document.getElementById('div1');
var oTxt=document.getElementById('txt1');
clearInterval(timer);
timer=setInterval(function() {
var speed=(iTarget-oDiv.offsetTop)/6;
//alert(iTarget-oDiv.offsetTop);
//alert(iTarget);
//alert(speed);
speed=speed>0?Math.ceil(speed):Math.floor(speed); if(oDiv.offsetHeight==iTarget)
{
clearInterval(timer);
}
else
{
document.title=iTarget ;
oTxt.value=oDiv.offsetTop;
//oTxt.style.top=oTxt.offsetTop+speed+'px';
oDiv.style.top=oDiv.offsetTop+speed+'px';
//oTxt.style.top=oDiv.offsetTop+speed+'px';
}
},30);
} </script>
</head> <body style="height:2000px;">
<input type="text" id="txt1" style="position:fixed; right:0; top:0";/>
<div id="div1"></div>
</body>
</html>

js屏幕上下滚动条的更多相关文章

  1. 利用JS实现自定义滚动条

    一般默认的滚动条会比较丑,我们可以用简单的js实现自定义滚动条的功能: 代码如下: <!doctype html> <html> <head> <meta c ...

  2. Python selenium webdriver设置js操作页面滚动条

    js2 = "window.scrollTo(0,0);" #括号中为坐标 当不知道需要的滚动的坐标大小时: weizhi2 = driver.find_element_by_id ...

  3. python3 + selenium 使用 JS操作页面滚动条

    js2 = "window.scrollTo(0,0);" #括号中为坐标 当不知道需要的滚动的坐标大小时: weizhi2 = driver.find_element_by_id ...

  4. java selenium webdriver处理JS操作窗口滚动条

    未经作者允许,禁止转载!!! java selenium webdriver处理JS操作窗口滚动条 java selenium webdriver处理JS操作窗口滚动条 import org.open ...

  5. js动态移动滚动条至底部示例

    使用js动态移动滚动条至底部. var currentPosition,timer;  function GoBottom(){  timer=setInterval("runToBotto ...

  6. js滚动显示: 滚动条置顶/底

    <script> //当聊天室的内容超出页面范围时, 如何让页面刷新后 显示最下面的内容 document.getElementByIdx ( 'chatboard').scrollTop ...

  7. 纯JS自定义网页滚动条

    前言 由于最近在公司很忙,没什么时间更新,忙中抽时间做了一个JS滚动条,因为火狐浏览器与谷歌浏览器的滚动条自定义样式过于麻烦,所以我打算自己写个方便改样式的滚动条 CSS <style> ...

  8. selenium+Python(Js处理浏览器滚动条)

    控制浏览器滚动条 有时候我们需要控制页面滚动条上的滚动条,但滚动条并非页面上的元素,这个时候就需要借助 js 是来进行操作.一般用到操作滚动条的会两个场景: 注册时的法律条文需要阅读,判断用户是否阅读 ...

  9. [Jquery] js获取浏览器滚动条距离顶端的距离

    需要用js获取滚动条距离窗口顶端的距离和js获取浏览器可视化窗口的大小  一.jQuery获取的相关方法 jquery 获取滚动条高度 获取浏览器显示区域的高度 : $(window).height( ...

随机推荐

  1. Linux中通配符

    通配符是由shell处理的, 它只会出现在 命令的“参数”里.当shell在“参数”中遇到了通配符时,shell会将其当作路径或文件名去在磁盘上搜寻可能的匹配:若符合要求的匹配存在,则进行代换(路径扩 ...

  2. 378. 有序矩阵中第K小的元素

    Q: A: //O(NK) class Solution { public: int kthSmallest(vector<vector<int>>& matrix, ...

  3. Linux常用命令英文全称与中文解释 (pwd、su、df、du等)

    https://blog.csdn.net/qq_40334837/article/details/83819735 Linux常用命令英文全称与中文解释 apt: Advanced Packagin ...

  4. n个点的最长公共子串(别人的模板) poj 3080

    没有理解代码.单纯记模板 题意:找最长的公共字串,长度相同就找字典序最小的(这一点wa了我13遍!!!)题解:kmp或者直接暴力列举当公共子串长度小于3时,有特判 #include<map> ...

  5. Go_goroutine初识

    package main import ( "fmt" ) func main() { /* 一个goroutine打印数字,另外一个goroutine打印字母,观察运行结果.. ...

  6. BufferedInputStream 介绍

    BufferedInputStream 介绍 BufferedInputStream 是缓冲输入流.它继承于FilterInputStream.BufferedInputStream 的作用是为另一个 ...

  7. 哈希 Perl第六章

    哈希元素赋值: $hash{$some_key}  =  ‘something' 访问整个哈希: %some_hash = (’a' , '0' , 'b' , '1' , 'c' , '3') @a ...

  8. XFire客户端调用CXF服务端(四)

    前面章节:http://www.cnblogs.com/xiehongwei/p/8082337.html 已经开发出了CXF服务端,现在用XFire开发客户端调用CXF服务端,代码如下: impor ...

  9. Requests库网络爬虫实战

    实例一:页面的爬取 >>> import requests>>> r= requests.get("https://item.jd.com/1000037 ...

  10. Selenium元素定位之页面检测技巧

    我们在进行web自动化测试的时候进行XPath或者CSS定位,需要检测页面元素定位是否正确,如果用脚本去检测,那么效率是极低的. 一般网上推选装额外的插件来实现页面元素定位检测 如:firebug. ...