FF下出现问题,其他浏览器测试没有问题执行 document.documentElement.style.overflow = 'hidden';  在火狐下总是跳到页面头部而其他浏览器为当前位置为什么???如何能让他跟其他浏览器一样不跳到页面头部???<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="x-ua-compatible" content="ie=emulateie7" />
<title></title>
</head><body>    <div style="height:3000px;"></div><script>
window.onload = function(){
     window.scrollTo(0, 2000);
setTimeout(function(){
 alert('隐藏');
 document.documentElement.style.overflow = 'hidden'; 
},1000);
setTimeout(function(){
 alert('显示');
 document.documentElement.style.overflow = ''; 
},3000);};
</script>
</body></html>

解决方案 »

  1.   

    chrome也不正常,每次显示都执行scrollTo呢
      

  2.   

     document.documentElement 解析不一样同时设置  document.bodystyle.overflow = 'hidden';  试试 
      

  3.   


    不好意思,可能我加上这句误导了你。
    我加上这句是为了页面加载完的时候让页面跳到下面。以免你得手动滚动鼠标到页面下面。问题主要是   加上这句后  document.documentElement.style.overflow = 'hidden';  不管当前滚动条在哪个位置  在FF下都会跳到页面头部
      

  4.   


     document.documentElement 解析所有浏览器都是  html节点找到解决方法了。非常感谢回答~设置的时候:
    1、Y轴坐标 
    2、document.documentElement.style.cssText = 'overflow:hidden;padding-right:17px;';
    3、window.scrollTo(0, Y轴坐标 );还原的时候:
    1、Y轴坐标 
    2、document.documentElement.style.cssText = '';
    3、window.scrollTo(0, Y轴坐标 );