display the page when completely loaded

Discussion in 'JavaScript' started by amol.gupta, Sep 2, 2009.

  1. #1
    Hi,
    I want to make such a script that,
    When the user clicks login, a GIF image is displayed untill the whole page is loaded or atleast for about 5 seconds and loading the pages is in the background.Much like it is in gmail and paypal.
    how can this be done??I was thinking of some function like onCompleteLoad as we use
    <body onLoad=function()>

    or some other meathod
     
    amol.gupta, Sep 2, 2009 IP
  2. caprichoso

    caprichoso Well-Known Member

    Messages:
    433
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    110
    #2
    You can do it easily with jQuery like this: http://www.drk.com.ar/docs/photos/villa-de-merlo-san-luis-argentina.php

    You have to add a DIV with an id like loading to show the loading message. And another DIV with the actual content which should start with style display: none; using another id.

    Then bind the onload event with jQuery and switch visible and insivible DIVs:

    <script type="text/javascript" >
      $(document).ready(function(){
       $('#loading').addClass('hidden');
       $('#contenido').removeClass('hidden');
      });
      </script>
    Code (markup):
     
    caprichoso, Sep 5, 2009 IP