加载消息显示在顶部而不是中间

时间:2012-10-01 14:02:34

标签: html

我想在页面加载时使用ajax显示加载消息。我有代码,但消息显示在顶部..我希望它在屏幕中间.. 我该怎么办 ?代码段如下:

 <div id='loadpage'>
      <table height=100% width=100% border=0>
           <tr height=100%>
                <td width=100% align=center valign=center>Please Wait</td>
           </tr>
      </table>
 </div>
 var progressTimeID = setTimeout("document.getElementById('loadpage').innerHTML='<table style=\"height:100%;\" width=100% border=0><tr height=100%>    <td width=100% align=center valign=center>Please Wait</td></tr></table>';", 1000);
clearTimeout(progressTimeID);
提前thnx

3 个答案:

答案 0 :(得分:0)

我确信这是因为你height=100% 100%的一切都没有。因此,请确保所有父母都有一个明确的身高。甚至你的身体。

答案 1 :(得分:0)

您需要在CSS中将htmlbodydiv#loadpage设置为height:100%

html,
body,
div#loadpage
{
    width: 100%;
    height: 100%;
}

答案 2 :(得分:0)

你走了:

修改

<html>
<head>

<script>

    function load_show() {

        document.getElementById('loadpage').innerHTML = "<img src=\"http://websurvey.textalk.se/en/pics/ajax-loader-big.gif\" />";

    }

    function show_div() {

        var progressTimeID = setTimeout(function(){load_show()}, 1000);

    }

</script>

<style>

    body {

        background: #fff;

    }

    #loadpage {

        position: absolute;
        display: block;
        top: 50%;
        left: 50%;
        margin-top: -33px;
        margin-left: -33px;
        width: 66px;
        height: 66px;

    }

    #click {

        position: absolute;
        top: 20px;
        left: 50%;
        margin-left: -50px;
        width: 100px;
        height: 20px;
        cursor: pointer;

    }

</style>

</head>
<body>

<div id="click" onclick="show_div()">
    show loader
</div>

<div id="loadpage">
    CONTENT
</div>

</body>
</html>
  • 请不要使用表格布局。
  • 启动后无法清除超时。它会制动它以便它不会执行......