点击向下滑动, 如果要滚动的那个div的总高度,已经到边缘了 ,点击就不再滚动.....谁来帮忙修改下这个JS? O(∩_∩)O谢谢了啊。 这个JS也是一位热心的CSDN帮忙写的。<div style="width:100px;height:300px;background-color:red;overflow:hidden">
<div id="a" style="width:100px;height:100px;background-color:gray;margin-top:0px">
</div>
</div>
<input type="button" value="button" onclick="abc()">
<script type="text/javascript">
var i=0;
var sd=2;
var time;
function abc()
{
time=setTimeout("abc()",10); if(i<50)
{
document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+sd+"px";
i=i+sd;
}
else
{
clearTimeout(time);
i=0;
}
}
</script>
<div id="a" style="width:100px;height:100px;background-color:gray;margin-top:0px">
</div>
</div>
<input type="button" value="button" onclick="abc()">
<script type="text/javascript">
var i=0;
var sd=2;
var time;
function abc()
{
time=setTimeout("abc()",10); if(i<50)
{
document.getElementById("a").style.marginTop=document.getElementById("a").style.marginTop.replace("px","")-0+sd+"px";
i=i+sd;
}
else
{
clearTimeout(time);
i=0;
}
}
</script>
解决方案 »
- IE6 兼容问题 很急很急很急!!!!!
- 删除table中的checkbox问题~ 在线等 100分奉上
- JS中有没有类似c中宏的概念
- 在js脚本中怎么先加载一个frame页面,加载完成后,再执行frame页面中的函数?
- 如何判断输入框的内容超出了输入框的显示宽度(即左侧的字符不显示时)??
- javascript 操作table样式
- 如何实现自动显示
- 如何区分出英文和中文的字符串的长度??急
- 用window.open打开过后的窗口如何更改menubar和toolbar的属性值
- 如何实现点击锚链接的当前项目就改变样式?在线等。
- 滚动问题,在IE中不动....Firefox和opera中没事...新手求指教
- 请问一个有关FireFox起始页面的问题
<div id="a" style="width:100px;height:100px;background-color:gray;margin-top:0px">
</div>
</div>
<input type="button" value="button" onclick="abc()">
<script type="text/javascript">
var i=0;
var sd=2;
var time;
var h;function abc(){
time = setTimeout("abc()", 10);
var obj = document.getElementById("a");
h = parseInt(document.getElementById("a").style.marginTop.replace("px", "")) + sd; if(i < 50 && h + obj.offsetHeight <= obj.parentNode.offsetHeight){
document.getElementById("a").style.marginTop = h + "px";
i = i + sd;
}else{
clearTimeout(time);
i = 0;
}
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>openDiv.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var speed = 50;
var maxheight = 450;
//点击checkBox引发此函数
function divPopup(event, item){
var ruleDiv = document.getElementById("smsDiv");
if(item.checked){
DivShow(ruleDiv);
}else{
DivHide(ruleDiv);
}
}
//DIV展开与收起的两个函数
function DivShow(item) {
var temp = item.style.height;
item.style.height = parseInt(temp.substring(0, temp.length - 2)) + speed + "px";
temp = item.style.height;
if(parseInt(temp.substring(0, temp.length - 2)) < maxheight){
setTimeout(function () {
DivShow(item);
}, 100);
}
}
function DivHide(item) {
var temp = item.style.height;
item.style.height = parseInt(temp.substring(0, temp.length - 2)) - speed + "px";
temp = item.style.height;
temp = parseInt(temp.substring(0, temp.length - 2));
if(temp > 0){
setTimeout(function () {
DivHide(item);
}, 100);
}
}
</script>
</head>
<body>
<input type="checkbox" onclick="divPopup(event, this)"/>
<div id="smsDiv" style="border: 1px solid red; width: 200px; height: 200px; background-color: #CCCCFF;"></div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>testFor.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var i=0;
var sd = 2;
var time;
var h = 0;
function abc() {
time = setTimeout("abc()", 10);
var boxH = document.getElementById("oBox").style.height.replace("px","");//外层div的高度
var aSty = document.getElementById("a").style;
var top = aSty.marginTop.replace("px","");
var aH = aSty.height.replace("px","");//滑动div的高度
var totalH = (Number(boxH) - Number(aH));
h = top - 0 + sd;
if(i<50 && h <= totalH) {
document.getElementById("a").style.marginTop = h + "px";
i = i + sd;
} else {
clearTimeout(time);
i = 0;
}
document.getElementById("show").value = h + ":" +totalH;
}
</script> </head>
<body>
<div id="oBox" style="width:100px;height:300px;background-color:red;overflow:hidden">
<div id="a" style="width:100px;height:100px;background-color:gray;margin-top:0px">
</div>
</div>
<input type="button" value="button" onclick="abc()">
<input type="text" id="show">
</body>
</html>
改好了