Hallo Andreas,
ja klar, Du hast Recht. Ich hatte nur den Code für einen Ticker gepostet, weil es mir eigentlich darum ging, die this.* Konstrukte irgendwie umzuschreiben. Den vollständigen Code für zwei Ticker findest Du unten. Ich habe allerdings sämtliche Funktionen dupliziert. Ist bestimmt viel zu umständlich, aber einfach mit einZweiterTicker.* geht es nicht, weil sich die beiden in unterschiedliche Richtungen mit unterschiedlichen Parametern (z.B. speed) bewegen sollten.
Inzwischen läuft es immerhin, nachdem ich die init-Funktion auch noch geteilt habe. Das scheint der Fehler gewesen zu sein. Aber das Ganze verhält sich noch sehr komisch. Wenn ich speed_a für Angebot erhöhe, wird dieser Ticker (Angebot) gleich gar nicht mehr angezeigt.
Gruß, Sabine
userAgent = navigator.userAgent.toLowerCase();
n4 = document.layers;
ie = (document.all && userAgent.indexOf("mac")<0);
w3c = document.documentElement;
dhtml = ((n4 || ie || w3c) && userAgent.indexOf("aol")<0);
function Ticker(name, parentId, id, hoehe){
this.name_t = name;
this.hoehe = hoehe;
this.el_r_t = n4? document.layers[parentId] : ie? document.all[id] : document.getElementById(id);
this.el_t = n4? document.layers[parentId].document.layers[id] : ie? document.all[id] : document.getElementById(id);
this.css_r_t = n4? this.el_r_t : this.el_r_t.style;
this.css_t = n4? this.el_t : this.el_t.style;
this.inhaltHoehe = n4? this.el_t.document.height : this.el_t.offsetHeight;
this.inhaltY = 106;
this.speed_t = 1;
this.hoch = TickerHoch;
this.stop_t = TickerStop;
}
function Angebot(name, parentId, id, breite){
this.name_a = name;
this.breite = breite;
this.el_r_a = n4? document.layers[parentId] : ie? document.all[id] : document.getElementById(id);
this.el_a = n4? document.layers[parentId].document.layers[id] : ie? document.all[id] : document.getElementById(id);
this.css_r_a = n4? this.el_r_a : this.el_r_a.style;
this.css_a = n4? this.el_a : this.el_a.style;
this.inhaltBreite = n4? this.el_a.document.width : this.el_a.offsetWidth;
this.inhaltX = 146;
this.speed_a = 1;
this.breit = AngebotLinks;
this.stop_a = AngebotStop;
}
function TickerHoch() {
this.stop_t();
this.timer_t = setTimeout(this.name_t+".hoch()", 25);
if (this.inhaltY>-this.inhaltHoehe)
{
if (this.inhaltY==15)
{
this.stop_t();
this.timer_t = setTimeout(this.name_t+".hoch()", 3000)
}
n4? this.css_t.visibility = "show" : this.css_t.visibility = "visible";
n4? this.css_r_t.visibility = "show" : this.css_r_t.visibility = "visible";
this.inhaltY -= this.speed_t;
this.css_t.top = this.inhaltY;
}
else
{
n4? this.css_t.visibility = "hide" : this.css_t.visibility = "hidden";
n4? this.css_r_t.visibility = "hide" : this.css_r_t.visibility = "hidden";
this.inhaltY = this.hoehe;
this.stop_t();
init_t();
}
}
function AngebotLinks() {
this.stop_a();
this.timer_a = setTimeout(this.name_a+".breit()", 1);
if (this.inhaltX>-this.inhaltBreite)
{
if (this.inhaltX==0)
{
this.stop_a();
this.timer_a= setTimeout(this.name_a+".breit()", 3000)
}
n4? this.css_a.visibility = "show" : this.css_a.visibility = "visible";
n4? this.css_r_a.visibility = "show" : this.css_r_a.visibility = "visible";
this.inhaltX -= this.speed_a;
this.css_a.left = this.inhaltX;
}
else
{
n4? this.css_a.visibility = "hide" : this.css_a.visibility = "hidden";
n4? this.css_r_a.visibility = "hide" : this.css_r_a.visibility = "hidden";
this.inhaltX = this.breite;
this.stop_a();
init_a();
}
}
function TickerStop() {
if (this.timer_t) clearTimeout(this.timer_t);
}
function AngebotStop() {
if (this.timer_a) clearTimeout(this.timer_a);
}
z_angebot=-1; // Anzeige beginnt mit Angebot 0
z_ticker=-1;
function init_a(){
if (!dhtml) return;
if (z_angebot<5) { z_angebot++; }
else { z_angebot=0 }
einAngebot = new Angebot("einAngebot", "angebotDiv"+z_angebot, "angebotText"+z_angebot, 146);
einAngebot.breit();
}
function init_t(){
if (!dhtml) return;
if (z_ticker<10) { z_ticker++; }
else { z_ticker=0 }
einTicker = new Ticker("einTicker", "tickerDiv"+z_ticker, "tickerText"+z_ticker, 106);
einTicker.hoch();
}