就是想做一个很简单的功能,双击屏幕自动滚动。代码百度很多,虽然几乎都是重复的:var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",10);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
但是有个致命的弱点,一旦和 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
这句话同时出现,JS 就失效。。但是把那句话删掉,首先好像是不合规范什么的,其次是我有的 CSS 倒失效了。。有没有大哥知道怎么解决的?给指点下吧。。谢谢!

解决方案 »

  1.   

    http://www.lslnet.com/linux/dosc1/19/linux-190217.htm
      

  2.   

    var currentpos,timer;function initialize()
    {
    timer=setInterval("scrollwindow()",10);
    }
    function sc(){
    clearInterval(timer);
    }
    function scrollwindow()
    {
    window.scrollBy(0,1);
    }
    document.onmousedown=sc;
    document.ondblclick=initialize;
    试试
      

  3.   

    http://hi.baidu.com/saden/blog/item/d55d9113b3c0ce836438db69.html
      

  4.   

    使用document.documentElement和<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML />兼容
    -----------------------------------------------------------------------------------
    var currentpos,timer;
    function initialize()
    {
        timer=setInterval("scrollwindow()",10);
    }
    function sc(){
    clearInterval(timer);
    }
    function scrollwindow()
    {
    currentpos=document.documentElement.scrollTop;
    window.scroll(0,++currentpos);
    if (currentpos != document.documentElement.scrollTop)
    sc();
    }
    document.onmousedown=sc
    document.ondblclick=initialize