1

Using only HTML, CSS, and Javascript, has the web development world got to a stage where it is possible to display a loading message on the screen until absolutely everything has downloaded before the web page is displayed on the screen?

For example, display "loading", until all html, css, javascript, images etc etc have downloaded and can be displayed without the user seeing bits of the website still appearing after the load message has gone?

UPDATE, .LOAD DOESN'T WORK:

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title></title>

        <script  type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

        <script type="text/javascript">

            $(document).load(function(){

                alert("loaded");

            });

        </script>
    </head>
    <body>

    </body>
</html>
4

3 回答 3

2

毫无疑问,这将通过 jQuery 和 javascript 实现:

$(function(){

    $('body').addClass('loader'); // this will show the loading gif

    $(window).load(function(){
        $('body').removeClass('loader'); // remove the loader when window gets loaded.
        $('#wrapper').show();    // show the wrapper div after everything loaded.
    });

});
于 2012-12-18T17:08:45.533 回答
1

你可以使用$(window).load()

$(window).load(function(){
    alert("");
})
于 2012-12-18T17:01:14.247 回答
-1

是的,这里<body>onLoad描述的属性,例如:

<script type="text/javascript">
function done() {
    document.getElementById("loadingtext").innerHTML = "";
}
</script>

<body onload="done()">
<div id="loadingtext">Loading...</div>

但是,当然,使用框架更容易。

于 2012-12-18T17:02:03.260 回答