Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    stay on page until other is loades

    Hallo
    i need heeeeeeeelp
    I want to stay on page until other is loaded, with animated gif.

    Lets say i want javascript to do something like this:

    Stay on this page while the other is loaded and while page is loading play gif in this div
    (some div, for example loading

    Hope its clear
    Thank you very much for any advice

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Presumably you mean pre-load the destination page before showing it.

    This has been requested previously.

    Don't use it on destination sites that don't allow iframing.
    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title>Test Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type='text/css'>
    a,a:link,a:visited{padding:0.2em;}
    a:hover,a:active{padding:0.2em;text-decoration:none}
    #loadSign {display:none; position:fixed; top:50%; left:30%; width:40%; padding:1em; text-decoration:blink; color:#fff; background-color:#0c0; text-align:center; border-radius:0.2em }
    </style>
    <script type='text/javascript'>
    
    function docPreload( ifId, actionId )
    {
      var args = docPreload.arguments,
          showElem,
          ifr;  
        
      function init( /*2843294C6F676963416C69*/ )
      {
        var ifLoadHandler;
            
        ifr = document.getElementById( ifId );
        
        showElem = document.getElementById( actionId );    
             
        installHandler( ifr, 'onload', ifLoadHandler = ( function( iframe ){ return function(){ showElem.style.display = 'none'; top.location.href = iframe.src; } } )( ifr ) );
    
        installHandler( ifr, 'onerror', ifLoadHandler );
    
        for( var i = 2; args[ i ]; i++ )
          installHandler( document.getElementById( args[ i ] ), 'onclick', f );
      }
    
      installHandler( window, 'onload', init );
      
      function f( e )
      {
        var elem = e.srcElement || e.target;
    
        while( elem && elem.nodeName != 'A' )
          elem = elem.parentNode;
    
        if( elem )
        {
          e.preventDefault ? e.preventDefault() : e.returnValue = false;
          showElem.style.display = 'inline';
          ifr.src = elem.href;  
        }
      }
    
      function installHandler( obj, evt, func )
      {
        window.attachEvent ? obj.attachEvent(evt,func) : obj.addEventListener( evt.replace( /^on/i, "" ), func, false);
      }
    }
    </script>
    </head>
    <body>
    <script type='text/javascript'>
     docPreload( 'myIframe', 'loadSign', 'linkA', 'linkB' ); /* OK to add more link IDs */
    </script>
     <iframe src='initial.htm' id='myIframe' width='0' height='0' style='display:none'></iframe>
     <a href='http://wikipedia.com' id='linkA'>WikiPedia</a><p>
     <a href='http://ebay.com' id='linkB'>EBay</a><p>
     <span id='loadSign' ><b> LOADING... </b></span>
    </body>
    </html>


  •  

    Posting Permissions

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