How can I make the browser wait to display the page until it's fully loaded?

I hate how you can actually see webpages load. I think it'd be much more appealing to wait until the page is fully loaded and ready to be displayed, including all scripts and images, and then have the browser display it. So I have two questions...

  • How can I do this?
  • I'm a total noob to web development, but is this common practice? If not, why?
  • Thanks in advance for your wisdom!


    This is a very bad idea for all of the reasons given, and more. That said, here's how you do it using jQuery:

    <body>
    <div id="msg" style="font-size:largest;">
    <!-- you can set whatever style you want on this -->
    Loading, please wait...
    </div>
    <div id="body" style="display:none;">
    <!-- everything else -->
    </div>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#body').show();
        $('#msg').hide();
    });
    </script>
    </body>
    

    If the user has JavaScript disabled, they never see the page. If the page never finishes loading, they never see the page. If the page takes too long to load, they may assume something went wrong and just go elsewhere instead of *please wait...*ing.


    I think this is a really bad idea. Users like to see progress, plain and simple. Keeping the page at one state for a few seconds and then instantly displaying the loaded page will make the user feel like nothing is happening and you are likely to lose visits.

    One option is to show a loading status on your page while stuff processes in the background, but this is normally reserved for when the site is actually doing processing on user input.

    http://www.webdeveloper.com/forum/showthread.php?t=180958

    The bottom line, you at least need to show some visual activity while the page is loading, and I think having the page load in little pieces at a time is not all that bad (assuming you aren't doing something that seriously slows down page load time).


    There is certainly a valid use for this. One is to prevent people from clicking on links/causing JavaScript events to occur until all the page elements and JavaScript have loaded.

    In IE , you could use page transitions which mean the page doesn't display until it's fully loaded:

    <meta http-equiv="Page-Enter" content="blendTrans(Duration=.01)" />
    <meta http-equiv="Page-Exit" content="blendTrans(Duration=.01)" />
    

    Notice the short duration. It's just enough to make sure the page doesn't display until it's fully loaded.

    In FireFox and other browsers, the solution I've used is to create a DIV that is the size of the page and white, then at the very end of the page put in JavaScript that hides it. Another way would be to use jQuery and hide it as well. Not as painless as the IE solution but both work well.

    链接地址: http://www.djcxy.com/p/96872.html

    上一篇: 没有什么意思

    下一篇: 如何让浏览器等待显示页面,直到完全加载?