Welcome to probably the most useless blog post on the web.

Now you can happily animate stuff in the address bar (do you remember the nineties and nice status bar animations ? :) ) .

The beautiful online demo can be found here : Demo of animated address bar

HTML:
  1. <title>Totally usesless 'ajax' 'loading' image in the address bar as a spinning thing</title>
  2. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  3. <meta name="author" content="AF83.com" />
  4. <script language="JavaScript">

JavaScript:
  1. <!--
  2. /**
  3. *  Copyright (c) 2007, AF83
  4. *  All rights reserved.
  5. *
  6. *  Redistribution and use in source and binary forms, with or without modification,
  7. *  are permitted provided that the following conditions are met:
  8. *
  9. *  1° Redistributions of source code must retain the above copyright notice,
  10. *  this list of conditions and the following disclaimer.
  11. *
  12. *  2° Redistributions in binary form must reproduce the above copyright notice,
  13. *  this list of conditions and the following disclaimer in the documentation
  14. *  and/or other materials provided with the distribution.
  15. *
  16. *  3° Neither the name of AF83 nor the names of its contributors may be used
  17. *  to endorse or promote products derived from this software without specific
  18. *  prior written permission.
  19. *  THIS SOFTWARE IS PROVIDED BY THE COMPANY AF83 AND CONTRIBUTORS "AS IS"
  20. *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21. *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  23. *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  27. *  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  29. *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. *  @copyright  2007 AF83 Ori Pekelman
  32. *  @license    BSD License (3 Clause) http://www.opensource.org/licenses/bsd-license.php
  33. *  @package    Useless Stuff
  34. */
  35. // Configure :
  36. var TextBefore=' ...  Loading ... ';
  37. // End configuration
  38. var AddressBarLoaderTimeOut;
  39. var OriginalLocationHash = document.location.hash; // so we can restore original url
  40.  
  41. function loc_hash(a){
  42.  document.location.hash =TextBefore+a;
  43. }
  44.  
  45. function spinStart(){
  46.     AddressBarLoaderTimeOut=setTimeout("spinStart()",100);
  47.     loc_hash("|");
  48.     loc_hash("/");
  49.     loc_hash("-");
  50.     loc_hash("");
  51.     loc_hash("|");
  52.     loc_hash("/");
  53.     loc_hash("-");
  54.  }
  55.  function spinStop(){
  56.      document.location.hash=OriginalLocationHash;
  57.      clearTimeout(AddressBarLoaderTimeOut) ;
  58.      }
  59. // -->

HTML:
  1. </script>
  2. </head>
  3. <h1>Totally usesless 'ajax' 'loading' image in the address bar as a spinning thing</h1>
  4. <div style="margin:100px;height:100px;width:100px; background-color:#333;font-size:18;color:white;" onclick="spinStart();">Click on me to start address bar ajax loader</div>
  5. <div style="margin:100px;height:100px;width:100px; background-color:#333;font-size:18;color:white;" onclick="spinStop();">Click on me to stop</div>
  6. </body>
  7. </html>

5 Responses to “Totally useless ‘ajax’ ‘loading’ image in the address bar as a spinning thing”

  1. j.ducastel Says:

    Doesn’t work on Opera : it stucks to the loading step.

  2. Ori Pekelman Says:

    peut-être qu’il faut utiliser window.location.replace pour opera? mystère. J’ouvre toute de suite un gros ticket prioritaire :)

  3. Bruno Michel Says:

    Ce genre de technique est utilisé par des bibliothèques comme Really Simple History [http://code.google.com/p/reallysimplehistory/] pour créer un historique sur des requêtes AJAX et permettre de bookmarker un état d’une page après une requêtes AJAX. Really Simple History contient beaucoup de code spécifiques à un navigateur, ce qui laisse penser que ce genre de manipulation est très peu portable. Dans le cas particulier d’Opera, la lecture du code de Really Simple History (très bien documenté soit dit au passage) me laisse penser qu’opera n’accepte pas de modifier le window.location plus d’une fois toutes les 400 millisecondes.

  4. Teddy Brown Says:

    Whoa! No, no, and no! Basically destroyed my session history … I couldn’t even come back to this page and had to find it in Google again.

    I hated these effects back in the day before I could selectively disable Javascript abilities, and I hate this one even more ;)
    What would be a neat idea would be to change the favicon to an animated loader, and change it back to static when the page is done. I know Firefox supports animated favicons, but I doubt any other browsers do … IE certainly does not.

    <link rel=”shortcut icon” href=”favicon.gif” type=”image/gif” />

    Wouldn’t be hard to change the href in Javascript … perhaps I’ll give it a shot and see what comes of it.

  5. Ori Pekelman Says:

    He he. I am sure there are worlds of annoying stuff yet to be invented. Maybe we should make a contest?

Leave a Reply

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.0 License.