如何在完成加载后停止向下滚动页面?

时间:2016-11-04 13:34:51

标签: javascript php jquery

我有一个运行bash脚本的php页面,其输出打印在我的页面上。我使用以下函数来显示输出:

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>

添加window.scrollTo(0,document.body.scrollHeight),以便在新内容不断打印在页面上时页面滚动到底部。但即使页面停止加载并且没有添加新内容,它也会继续下降。如果我向上滚动,它会自动滚动到底部。这是什么问题?任何帮助将不胜感激。

显示数据的html:

function showOutput()
{
    var server=$('#serverSelect').val();
    $.ajax({
    url: '/marketplace/static/php/web/deployment.php',
    dataType: 'text',
    data : {
            "getOutput" :"getOutput",   
    },
    type:'POST',
    success:function(result){   
        $('#result').html(result);
        window.scrollTo(0,document.body.scrollHeight);
        if(buildStatus==1)
        {
            showOutput();
        }
        else if(end==0)
        {
            end=1;
            setTimeout(showOutput, 10000);
        }
    }
    });
}

0 个答案:

没有答案