SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question display div/img during onload

    Hello. Could anyone point me in the direction of a script for displaying an image to indicate that the page is loading? Thanks in advance .

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    For starters, have you tried this website? It's excellent.

    Also, what you are after sounds like it would annoy the hell out of some users, like me. My browser is perfectly capable of telling me that the page is loading. Why do you want to do this?

  3. #3
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Che Guava View Post
    Hello. Could anyone point me in the direction of a script for displaying an image to indicate that the page is loading? Thanks in advance .
    I do it like this:
    Code:
    <script type='text/javascript'>
    
    /*** Document 'Preloader'
    
    Outside of the your main containing or 'wrapper' div, create a 'loading message' 
    div of your choice, which may contain anything. Once its appearance is satisfactory,
    style it: display:none;
    
    Insert the code below in the document, outside of and below both the wrapper div and
    the 'loading' div.
    
    On the last line of this code, replace the IDs of the 'loading' div and the main div
    with the IDs of your own elements.
    The number 4000 represents a delay of 4 seconds, after which the main div is displayed
    if the document has not loaded.
    
    DO NOT style the 'wrapper' div: display:none;
    
    ***/
    
    (function(a0,a1) 
    {
     /*28432953637269707465726C617476652E636F6D*/  
     document.getElementById(a0).style.display='block';
     document.getElementById(a1).style.display='none';
    
     setTimeout( (function(a,b)
     {
      var prefix=window.attachEvent?'on':'';
    
      eventAdd=prefix?window.attachEvent:window.addEventListener;
      var  a=arguments[0], b=arguments[1];
    
      var showContent=function()
      {
       var A=a, B=b;
       document.getElementById(A).style.display='none';
       document.getElementById(B).style.display='block';
      }
    
      eventAdd(prefix+'load', showContent, false);
    
      return showContent;
    
     }(arguments[0],arguments[1])), arguments[2]);
    
    }('loadMsg','wrap', 4000));
    
    </script>
    You're welcome in advance.
    Last edited by Logic Ali; Feb 25, 2008 at 20:56.
    Tab-indentation is a crime against humanity.

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •