rebecca: hast du ein preloader-skript?

hi du,

ich stehe vor einem problem. ich möchte dass die bilder die für mein navigationsmenü geladen werden => vorgeladen werden. ich habe dass schon öfters auf webseiten gesehen weiss allerdings nicht mehr wo. ich habe zwar ein preloader-script. dieses leitet jedoch nach dem laden auf eine seite weiter. beim laden der seite soll jedoch statt des menüs der ladebalken zu sehen sein und nach dem laden eben das menü.

hast du zufällig ein solches skript?

merci im voraus!

rebecca

  1. Versuche es mit dieses:

    <html>
    <head>
    <title>Image preloader</title>
    <table width="100%" height="100%"><tr><td align="center" valign="middle">
    <script language="javascript">

    /*                                                    ,  ,       *\                                                      / / \                                                     (/ //_ \_
          .-._                                           ||  .  \        \  '-._                                 _,:__.-"/---\_ \   ______/___  '.    .-------------------------'~-'--.)__( , )\ \  '--.\_\_\_  \_\  /    |                              ,'    \)|\ |
          /_.-' _\ \ _:,_           Image Preloader          " ||   (
        .'__ _.' '-/,-~            Version 2.0              |/
            '. ___.> /=,|         Written by Kal Torak         |
             / .-'/_ )  |                                      |
             )'  ( /(/  '--------------------------------------'
                  \ "
    \*             '=='                                              */

    //This code can be used to postpone displaying the page until all (necessary) images
    //have been loaded. There is an indicator showing how far the loading has
    //proceeded. The script works for IE4+,NN4+ and Opera 5+.
    //The script can freely be used on any non-commercial sites as long as the
    //disclaimer as shown above remains unchanged at the top of the code.

    var $text='Preloading images...<BR><BR>'; //the text appearing above the indicator
    var $dir='images/'; //the directory of the images, like 'images/'
    var $files=new Array('img1.jpg','img2.jpg','img3.jpg'); //a list of the images
    var $url='next.html'; //url for the next page
    var $w=300; //width of the indicator in pixels
    var $h=30; //height of the indicator in pixels
    var $fg_color="#dd0000"; //color of the indicator
    var $bg_color="#dddddd"; //backgroundcolor of the indicator
    var $borderwidth=1; //borderwidth in pixels
    var $bordercolor='#000000';
    var $autocontinue=30; //time in seconds before auto continue, 0 for no continue

    document.write($text);

    if(document.layers){
      document.write('<table><tr><td><ilayer bgcolor="'+$bordercolor+'" name="d1" width="'+($w+2*$borderwidth)+'" height="'+($h+2*$borderwidth)+'">');
      document.write('<layer bgcolor="'+$bg_color+'" name="d2" top="'+$borderwidth+'" left="'+$borderwidth+'" width="'+($w)+'" height="'+($h)+'"></layer>');
      document.write('<layer bgcolor="'+$fg_color+'" name="d3" top="'+$borderwidth+'" left="'+$borderwidth+'" width="0" height="'+($h)+'"></layer></ilayer></td></tr></table>');
    }else{
      document.write('<div id="d1" style="background:'+$bordercolor+';width:'+($w+2*$borderwidth)+';height:'+($h+2*$borderwidth)+';position:relative;">');
      document.write('<div id="d2" style="background:'+$bg_color+';width:'+($w)+';height:'+($h)+';position:absolute;top:'+$borderwidth+';left:'+$borderwidth+';">');
      document.write('<div id="d3" style="background:'+$fg_color+';width:0;height:'+($h)+';position:absolute;top:0;left:0;"></div></div></div>');
    }

    $img=new Array();$done=new Array();$loaded=0;

    for($i=0;$i<$files.length;$i++){
      $img[$i]=new Image();
      $img[$i].src=$dir+$files[$i]
      $done[$i]=0;
    }

    function $loadpage(){
      if($autocontinue)
        clearTimeout($u);
      clearInterval($t);
      document.location=$url;
    }

    function $check(){
      $g=0;
      for($i=0;$i<$img.length;$i++){
        if($img[$i].complete&&$done[$i]==0){
          $done[$i]=1;
          $loaded++;
          $g=1;
        }
      }

    if($g){
        if(document.layers){
          document.layers['d1'].document.layers['d3'].clip.width=Math.round($loaded*$w/$img.length);
        }else{
          document.all['d3'].style.width=Math.round($loaded*$w/$img.length);
        }

    if($loaded==$img.length){
        $loadpage();
      }

    }
    }

    if($autocontinue)
      $u=window.setTimeout("$loadpage()",$autocontinue*1000)

    $t=window.setInterval("$check()",500);

    </script>
    </td></tr></table>
    </body></html>

    1. Ich habe dieses:

      <script language="JavaScript1.2">
      <!-- begin hiding

      startingColor = new Array() // <-- Nicht ändern!
      endingColor = new Array() // <-- Nicht ändern!

      // Hier alle Bilder angeben die vorgeladen werden sollen:
      var yourImages = new Array("images/*.gif","images/*.gif","images/*.jpg") // Ende Bilder
      var locationAfterPreload = "index2.html" // Hier die Seite angeben zu der nach Vorladen weitergeleitet werden soll
      var preloadbarWidth = 300 // Die Länge des Vorladestatusbalkens!
      var preloadbarHeight = 9 // Die Höhe des Vorladestatusbalkens
      var backgroundOfGradient = "#000000" // Die Hintergrundfarbe des Vorladebalkens

      // Startfarbwert des Vorladebalkens - Es muss dabei die der erste, dritte und fünfte Wert des entsprechenden Hexadezimalcodes angegeben werden
      startingColor[0] = "0"
      startingColor[1] = "0"
      startingColor[2] = "0"

      // Endfarbwert des Vorladebalkens - Es muss dabei die der erste, dritte und fünfte Wert des entsprechenden Hexadezimalcodes angegeben werden
      endingColor[0] = "0"
      endingColor[1] = "f"
      endingColor[2] = "0"

      // BEI PROBLEMEN:
      var gap = 7
      // BEI JAVASCRIPT ERROR mit diesem Wert experimentieren!!! 2 ist der minimale Wert!!!

      // AB HIER NICHTS MEHR ÄNDERN

      if (!document.all) location.replace(locationAfterPreload)
      var a = 10, b = 11, c = 12, d = 13, e = 14, f=15, i, j, ones = new Array(), sixteens = new Array(), diff = new Array();
      var convert = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"), imgLen = yourImages.length;
      var loaded = new Array(), preImages = new Array(), currCount = 0, pending = 0, h = 0, hilite = new Array(), cover = new Array();
      var num = Math.floor(preloadbarWidth/gap);
      for (i = 0; i < 3; i++) {
              startingColor[i] = startingColor[i].toLowerCase();
              endingColor[i] = endingColor[i].toLowerCase();
              startingColor[i] = eval(startingColor[i]);
              endingColor[i] = eval(endingColor[i]);
              diff[i] = (endingColor[i]-startingColor[i])/num;
              ones[i] = Math.floor(diff[i]);
              sixteens[i] = Math.round((diff[i] - ones[i])*15);
      }
      endingColor[0] = 0;
      endingColor[1] = 0;
      endingColor[2] = 0;
      i = 0, j = 0;
      while (i <= num) {
              hilite[i] = "#";
              while (j < 3) {
                      hilite[i] += convert[startingColor[j]];
                      hilite[i] += convert[endingColor[j]];
                      startingColor[j] += ones[j];
                      endingColor[j] += sixteens[j];
                      if (endingColor[j] > 15) {
                              endingColor[j] -= 15;
                              startingColor[j]++;
                      }
                      j++;
              }
              j = 0;
              i++;
      }
      function loadImages() {
              for (i = 0; i < imgLen; i++) {
                      preImages[i] = new Image();
                      preImages[i].src = yourImages[i];
                      loaded[i] = 0;
                      cover[i] = Math.floor(num/imgLen)*(i+1)
              }
              cover[cover.length-1] += num%imgLen
              checkLoad();
      }
      function checkLoad() {
              if (pending) { changeto(); return }
              if (currCount == imgLen) { location.replace(locationAfterPreload); return }
              for (i = 0; i < imgLen; i++) {
                      if (!loaded[i] && preImages[i].complete) {
                              loaded[i] = 1; pending++; currCount++;
                              checkLoad();
                              return;
                      }
              }
              setTimeout("checkLoad()",10);
      }
      function changeto() {
              if (h+1 > cover[currCount-1]) {
                      var percent = Math.round(100/imgLen)*currCount;
                      if (percent > 100) while (percent != 100) percent--;
                      if (currCount == imgLen && percent < 100) percent = 100;
                      defaultStatus = "Loaded " + currCount + " out of " + imgLen + " images [" + percent + "%].";
                      pending--;
                      checkLoad();
                      return;
              }
              eval("document.all.cell" + (h+1) + ".style.backgroundColor = hilite[h]");;
              h++;
              setTimeout("changeto()",1);
      }
      defaultStatus = "Loaded 0 out of " + imgLen + " images [0%]."
      // end hiding -->
      </script>

      1. Ich habe dieses:

        [Script]

        welches schon wegen weniger Kommentarzeilen den Vorzug verdient.

        1. Ich habe dieses:

          [Script]

          welches schon wegen weniger Kommentarzeilen den Vorzug verdient.

          sinnlosen---------------------^