求助:如何让页面一打开就可以自己向下滚动(内详) 滚动 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 本帖最后由 showbo 于 2013-08-08 17:54:19 编辑 firefox12,ie7,8,chrome都没有问题,测试过的,你什么浏览器 哦哦,我知道了,你的这段代码如果加上<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">就不起作用了,能不能让他符合这个标准啊? 忘记xhtml了,改成下面的就行了,back或者css1都可以了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><div style="height:1000px"></div><script> var timer, scrollHeight, viewHeight, step = 20, sTop = 0,isScrict=document.compatMode=='CSS1Compat'; document.onclick = function () { clearInterval(timer); } function Move() { //设置滚动前获取当前的的滚动高度和sTop比较,如果小于sTop或者和sTop的差距大于step定义的,说明拖拽过滚动条了 var nowScrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop); if (nowScrollTop < sTop || (nowScrollTop - top > step)) clearInterval(timer); sTop += step; document.documentElement.scrollTop = document.body.scrollTop = sTop; if (sTop + viewHeight > scrollHeight) {//滚动到底部 clearInterval(timer); document.documentElement.scrollTop = document.body.scrollTop = 0//跳转到顶部 } } window.onresize = function () { viewHeight = document[isScrict?'documentElement':'body'].clientHeight; scrollHeight = document[isScrict?'documentElement':'body'].scrollHeight; } window.onload = function () { window.onresize(); timer = setInterval(Move, 100); }</script> 非常感谢,都符合我的要求了,不过我加了一段控制导航浮动的js之后,页面在滚动到最底部之后不会自动返回顶部了,应该是这两段js略有冲突吧?function tools(){ var top=$(document).scrollTop(); if(($.browser.msie==true)&&($.browser.version==6.0)){ if(top>168)$("#box1_1").css({position:"absolute",top:top-168}); }else{ if(top>168)$("#box1_1").css({position:"fixed",top:0}); } if(top<=168)$("#box1_1").css({position:"static",top:0});}$(function(){ window.onscroll=tools; window.onresize=tools;});</script> 不要覆盖原来的onresize,改成这样,因为在onload中调用 window.onscroll获取视窗和滚动高作为是否滚动到页脚的代码//window.onscroll=tools;//window.onresize=tools;//===>$(window).bind({scroll:tools,resize:tools}) 关于span标签的 onmouseover 怪问题 javascript在指定的位置输入内容 window.location.reload(); 这句兼容性如何?可以兼容所有浏览器吗 appendChild应用的问题 setTimeout()函数如何设置自动选择执行自定义的函数? 求助:页面用到浮动框架,如何实现点击框架里面的内容,刷新主页面而不刷新框架里面的内容 急!!!如何调用[文件另存为... ]对话框? .的用法???没分了,帮忙啊~~~~ 大家帮我看看这段javascript的代码是怎么错了,真让我焦头烂额???? 高分求救,关于目录树中递归调用问题。 80分 关于json转换html的问题,应该是基础问题希望高手进吧 Extjs Combobox加载数据问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
就不起作用了,能不能让他符合这个标准啊?
<script>
var timer, scrollHeight, viewHeight, step = 20, sTop = 0,isScrict=document.compatMode=='CSS1Compat';
document.onclick = function () { clearInterval(timer); }
function Move() {
//设置滚动前获取当前的的滚动高度和sTop比较,如果小于sTop或者和sTop的差距大于step定义的,说明拖拽过滚动条了
var nowScrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
if (nowScrollTop < sTop || (nowScrollTop - top > step)) clearInterval(timer);
sTop += step;
document.documentElement.scrollTop = document.body.scrollTop = sTop;
if (sTop + viewHeight > scrollHeight) {//滚动到底部
clearInterval(timer);
document.documentElement.scrollTop = document.body.scrollTop = 0//跳转到顶部
}
}
window.onresize = function () {
viewHeight = document[isScrict?'documentElement':'body'].clientHeight;
scrollHeight = document[isScrict?'documentElement':'body'].scrollHeight;
}
window.onload = function () {
window.onresize();
timer = setInterval(Move, 100);
}
</script>
var top=$(document).scrollTop();
if(($.browser.msie==true)&&($.browser.version==6.0)){
if(top>168)$("#box1_1").css({position:"absolute",top:top-168});
}else{
if(top>168)$("#box1_1").css({position:"fixed",top:0});
}
if(top<=168)$("#box1_1").css({position:"static",top:0});
}
$(function(){
window.onscroll=tools;
window.onresize=tools;
});
</script>
//window.onresize=tools;
//===>
$(window).bind({scroll:tools,resize:tools})