Haze: Funktion und schleife.

Beitrag lesen

Ich fang mit dem Anfang an und erkläre das ganze stück für stück.
Vieleicht hilft das besser zu verstehen.

var div_Width  ='500px';
var div_Height ='25px';
var bg_Color   ='#ffffff';
var text_Speed = 9;

var a = [1,2,3,4,5,];
 a[0] = "text5";
 a[1] = "text4";
 a[2] = "text3";
 a[3] = "text2";
 a[4] = "text1";

var shuffle = function(){
  return Math.random()-0.5;
  setInterval(spawn, 1000);
};
 c = a.sort(shuffle)
-----------------------------------------------------------------
Das array ist meine Laufschrift, die daten die durch mein erzeugten container laufen und die sichtbar sind.

Dann kommt die var shuffle die ja eine funktion darstellt.
Ich hol mir mit return das array mische es und mit hilfe des Intervals,tue ich das jede sekunde.
Und wollah immer wenn ich auf die Homepage komme oder die seite neu lade kommt ein anderes array zum vorschein :).

-------------------------------------------------------------------------

var d = text_Speed;
var tag, virtuel;
var pos = parseInt(div_Height) - 1;

window.onload = function begin(){
if (document.getElementById) {
var cont = '<div id="CONTAINERNAME" style="position:relative;width:'+div_Width+';height:'+div_Height+';overflow:hidden;background-color:'+bg_Color+'"';
cont    +='><div id="virtual" style="position:absolute;spacing:12px;left:5px;top:0px;font-family:;font-size:'+pos+'px;white-space:nowrap;"></div></div>';
document.getElementById('CONTAINERNAME').innerHTML = cont;
virtual = document.getElementById("virtual");
virtual.style.left=(parseInt(div_Width)+10)+"px";
virtual.innerHTML='<span id="tx"><font color="#123456">'+a[0]+'</font><font color="#ff9900">'+a[1]+'</font><font color="#000000">'+a[2]+'</font><font color="#000000">'+a[3]+'</font><font color="000000">'+a[4]+'</font></span>';
tag = document.getElementById("tx").offsetWidth;
lefttime=setInterval("move()",150);}
}
function move(){
virtual.style.left = (parseInt(virtual.style.left)>(-10 - tag)) ?parseInt(virtual.style.left)-d+"px" :
parseInt(tWidth)+50+"px";}

-----------------------------------------------------------------------
Uhhh... da hab ich was vergessen...
Damit das Script auch bei euch tut müsst ihr bei CONTAINERNAME einen container mit css deklarieren wo der sozusagen virtuelle Container hineinkommt, also einfach den namen von dem Container den ihr bei css gemacht habt einfach bei CONTAINERNAME reinschreiben. Der hieß bei mir schon ls.

Ja die Console meldet mir bei der Funktion shuffel einen fehler aber warum tut es dann? ich kann es nicht erklären...

Naja auf jedenfall, nach einem durchlauf hört das script das gesamte scrip auf. Die Variablen werden wohl immernoch gemischt aber der rest macht eben nur einen durchlauf die for schleife wollt ich dazu benutzen das, das script durchgehend die laufschrift durchläuft (hier hänge ich ja auch gerade und habe gemeint das die forschleife die ich dahingefuchtelt habe mehr als fehl am platz ist. Tut mir leid bin wirklich nicht der beste erklärer oder Fragen steller...

Probiert es mit css container deklarieren oben im script den container namen reinschreiben und eine html datei dazu  oder hier das script:
----------------------------------------------------------------

var div_Width  ='500px';
var div_Height ='25px';
var bg_Color   ='#ffffff';
var text_Speed = 9;

var a = [1,2,3,4,5,];
 a[0] = "hallo";
 a[1] = "Wie";
 a[2] = "Geht";
 a[3] = "Es";
 a[4] = "Dir?";

var shuffle = function(){
  return Math.random()-0.5;
  setInterval(spawn, 1000);
};
 c = a.sort(shuffle)

var d = text_Speed;
var tag, virtuel;
var pos = parseInt(div_Height) - 1;

window.onload = function begin(){
if (document.getElementById) {
var cont = '<div id="flash" style="position:relative;width:'+div_Width+';height:'+div_Height+';overflow:hidden;background-color:'+bg_Color+'"';
cont    +='><div id="virtual" style="position:absolute;spacing:12px;left:5px;top:0px;font-family:;font-size:'+pos+'px;white-space:nowrap;"></div></div>';
document.getElementById('flash').innerHTML = cont;
virtual = document.getElementById("virtual");
virtual.style.left=(parseInt(div_Width)+10)+"px";
virtual.innerHTML='<span id="tx"><font color="#123456">'+a[0]+'</font><font color="#ff9900">'+a[1]+'</font><font color="#000000">'+a[2]+'</font><font color="#000000">'+a[3]+'</font><font color="000000">'+a[4]+'</font></span>';
tag = document.getElementById("tx").offsetWidth;
lefttime=setInterval("move()",100);}
}
function move(){
virtual.style.left = (parseInt(virtual.style.left)>(-10 - tag)) ?parseInt(virtual.style.left)-d+"px" :
parseInt(tWidth)+50+"px";}
---------------------------------------

<html>
<head>
<link rel="stylesheet" type="text/css" href="new2.css">
<script type="text/JavaScript" src="laufschrift.js">
</script>
<title></title>
</head>
<body>
<div id="flash"></div>
</body>
</html>
-------------------------------------------------------

css
html {
min-height:101%;
}
body {
// font-family:Agency FB,Candara,Calibri,Tahoma,Arial,Helvetica,sans-serif;
line-height: 150%;
color: #000000;
background-color: #464646;
margin: 0;
padding: 0;
}
#flash {
margin:auto;
position:relativ;
overflow:hidden;
height:25px;
width:600px;
background-color:#123456;
}
--------------------------------------------
Hoffe man kan das hier lesen habs jetzt nicht kontrolliert.