• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

mit JS in span schreiben

Status
Für weitere Antworten geschlossen.

Frank

Neues Mitglied
hi leuz,

ich hab mal wieder ein problem.

Ich hab mir ein Script kopiert. Dieses Script stellt einen Imagepreloader dar. Das coole: es hat einen Ladebalken, an dem man den vorgang sehen kann.
Zudem schreibt das Script in die Status anzeige (defaultstatus = "") den Fortschritt. Z.B: Es sind 5 von 12 Bildern geladen.

Nun mein Problem:

Ich möchte, dass das Script das nicht in die Statusanzeige schreibt, sondern auf die Website. Zudem möchte ich KEINE textarea und auch KEIN input type="text".
Benutze ich nun nur document.write wird der Rest der auf der Seite ist überschrieben (das will ich auch NICHT).

Ich dachte an eine Möglichkeit, in ein span zu schreiben. Also z.b:
document.getelementbyid('anzeige').write

Leider funktioniert dann gar nichts mehr ( weder die Anzeige noch der Ladebalken) .

Wie bekomme ich es hin, ohne input und textarea das auf meine seite zu schreiben?

Hier das Script:
Code:
<html>
<head>
<title>Titel der Homepage</title>
<script>
 function stoperror()
 {
 return true
 }
 window.onerror=stoperror
</script>
<script language="JavaScript1.2">
 startingColor = new Array()
 endingColor = new Array()
 var yourImages = new Array("header.jpg","Ja.jpg","Jaa.jpg","Nein.jpg","Neina.jpg");
 var locationAfterPreload = "start.html"
 var preloadbarWidth = 900
 var preloadbarHeight = 15
 var backgroundOfGradient = "#000022"
  // Anfangsfarbe des Ladebalken (Hex)
 startingColor[0] = "0"
 startingColor[1] = "0"
 startingColor[2] = "6"
 // Endfrabe des Ladebalken (Hex)
 endingColor[0] = "0"
 endingColor[1] = "0"
 endingColor[2] = "c"
 var gap = 1
 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 = "Es sind " + currCount + " Grafiken von " + imgLen + " Grafiken geladen >> [" + percent + "%].";
      pending--;
      checkLoad();
      return;
          }
     eval("document.all.cell" + (h+1) + ".style.backgroundColor = hilite[h]");;
     h++;
   setTimeout("changeto()",1);
        }
  defaultStatus = "Gerade wird die 1. von " + imgLen + " Grafiken Geladen [0%]."
</script>
</head>

<body bgcolor="#000000">
 <center>
  <font face="Verdana, Arial, Helvetica" size="2">
   <center>
    

</p>
    

</p>
    

</p>
    

</p>
    

<font color="ffffff">[b]Lade Grafiken...[/b] 

Bitte warten..

</font></p>
    </center>
    <font color="#FFFFFF">
<script language="JavaScript1.2">
<!--
 document.write('<table border="0" cellpadding="0" cellspacing="0" width="' + preloadbarWidth + '"><tr height="' + preloadbarHeight + '" bgcolor="' + backgroundOfGradient + '">');
 for (i = 0; i < num; i++) {
 document.write('<td width="' + gap + '" id="cell' + (i+1) + '"></td>');
 }
 document.write('</tr></table>');
 loadImages();
 // -->
 </script>
 </font>
 </center>
 </font>
  

</p>
   <p align="center">
  <font face="Verdana" color="#FFFFFF" size="1">
    <a href="Seiten/index.htm"><span style="text-decoration: none">
         <font color="#FFFFFF">Klicken Sie hier, falls keine Grafiken vorgeladen werden sollen</font></span>
        </a>
      </font>
      </p>
   </body>
   </html>
 
Werbung:
Status
Für weitere Antworten geschlossen.
Zurück
Oben