js屏幕上下滚动条
<!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屏幕上下滚动条的更多相关文章
- 利用JS实现自定义滚动条
一般默认的滚动条会比较丑,我们可以用简单的js实现自定义滚动条的功能: 代码如下: <!doctype html> <html> <head> <meta c ...
- Python selenium webdriver设置js操作页面滚动条
js2 = "window.scrollTo(0,0);" #括号中为坐标 当不知道需要的滚动的坐标大小时: weizhi2 = driver.find_element_by_id ...
- python3 + selenium 使用 JS操作页面滚动条
js2 = "window.scrollTo(0,0);" #括号中为坐标 当不知道需要的滚动的坐标大小时: weizhi2 = driver.find_element_by_id ...
- java selenium webdriver处理JS操作窗口滚动条
未经作者允许,禁止转载!!! java selenium webdriver处理JS操作窗口滚动条 java selenium webdriver处理JS操作窗口滚动条 import org.open ...
- js动态移动滚动条至底部示例
使用js动态移动滚动条至底部. var currentPosition,timer; function GoBottom(){ timer=setInterval("runToBotto ...
- js滚动显示: 滚动条置顶/底
<script> //当聊天室的内容超出页面范围时, 如何让页面刷新后 显示最下面的内容 document.getElementByIdx ( 'chatboard').scrollTop ...
- 纯JS自定义网页滚动条
前言 由于最近在公司很忙,没什么时间更新,忙中抽时间做了一个JS滚动条,因为火狐浏览器与谷歌浏览器的滚动条自定义样式过于麻烦,所以我打算自己写个方便改样式的滚动条 CSS <style> ...
- selenium+Python(Js处理浏览器滚动条)
控制浏览器滚动条 有时候我们需要控制页面滚动条上的滚动条,但滚动条并非页面上的元素,这个时候就需要借助 js 是来进行操作.一般用到操作滚动条的会两个场景: 注册时的法律条文需要阅读,判断用户是否阅读 ...
- [Jquery] js获取浏览器滚动条距离顶端的距离
需要用js获取滚动条距离窗口顶端的距离和js获取浏览器可视化窗口的大小 一.jQuery获取的相关方法 jquery 获取滚动条高度 获取浏览器显示区域的高度 : $(window).height( ...
随机推荐
- Sliding Window POJ - 2823 单调队列模板题
Sliding Window POJ - 2823 单调队列模板题 题意 给出一个数列 并且给出一个数m 问每个连续的m中的最小\最大值是多少,并输出 思路 使用单调队列来写,拿最小值来举例 要求区间 ...
- JavaScript错误-throw、try和catch
try 语句测试代码块的错误. catch 语句处理错误. throw 语句创建自定义错误. finally 语句在 try 和 catch 语句之后,无论是否有触发异常,该语句都会执行. JavaS ...
- 浅谈ABB机器人(工具坐标,工件坐标,有效载荷)
工具坐标(tool): 使tcl坐标偏移到工具上,例如焊接工作,使机器人工作点切入焊枪点上 mass:工具的重量 xyz:偏移距离的大小 验证:通过手动模式,切换至自定义工具,重定向 工件坐标(wob ...
- DB技能数据库里把技能伤害调整
1. MagID 技能代号 2. MagName 技能名称 3. Effect Type 效果类型(使用技能时角色的动作效果) 4. Effect 效果(技能产生的动画效果) 5. Spell 每次耗 ...
- noobSTL-1-配置器-0
noobSTL-1-配置器-0 0.前言 STL的配置器(allocator),也叫内存分配器,负责空间配置与管理,简单地说,就是负责管理内存的. 从实现的角度来看,配置器是一个实现了动态空间配置.空 ...
- [python]Python 字典(Dictionary) update()方法
update() 函数把字典dict2的键/值对更新到dict里.如果后面的键有重复的会覆盖前面的语法dict.update(dict2) dict = {'Name': 'Zara', 'Age': ...
- for each.遍历集合或数组使用
package seday11; import java.lang.reflect.Array;import java.util.ArrayList;import java.util.Collecti ...
- servlet中Request与response使用
服务器根据请求自动创建传入HttpServletRequest对象和HttpServletResponse对象 @Override protected void service(HttpServlet ...
- 常用的MQ命令
删除队列管理器 dltmqm QmgrName 启动队列管理器 strmqm QmgrName 如果是启动默认的队列管理器,可以不带其名字 停止队列管理器 endmqm QmgrName 受控停止 e ...
- HBase 启动后HMaster进程自动消失
原因分析 1.hadoop 与 hbase 版本不兼容,导致的异常. 2.log日志信息显示 org.apache.hadoop.hbase.TableExistsException: hbase:n ...