Wenn du von der Lightbox v1.0 sprichst, ginge dies recht einfach:
Hört sich ja super an, aber ich kann dir leider nicht ganz folgen. Ich post euch mal mein kompl. Script, vllt bringt das etwas mehr Licht ins Dunkel - bin am Ende mit meinem Latein :-/
<script type="text/javascript">
var bilddaten = [
{ description : "desc1", link : "http://www.test.de/bild1.jpg" },
{ description : "desc2", link : "http://www.test.de/bild2.jpg" }
];
window.onload = bildRotationStart;
function bildRotationStart () {
//bildIndex = Math.floor(bannerdaten.length * Math.random());"
bildIndex = "0"
var pElement = document.createElement("p");
pElement.id = "bild";
var aElement = document.createElement("a");
aElement.id = "bild-link";
aElement.href = bilddaten[bildIndex].link;
aElement.title = bilddaten[bildIndex].description;
aElement.target = "_blank";
var imgElement = document.createElement("img");
imgElement.id = "bild-bild";
imgElement.alt = "";
imgElement.src = "bilder/orgafoto/bild" + bildIndex + ".jpg";
aElement.appendChild(imgElement);
pElement.appendChild(aElement);
//document.body.insertBefore(pElement, document.body.firstChild);
document.getElementById("bild-container").appendChild(pElement);
// Starte den Wechsel-Intervall alle 4000 Millisekunden = 4 Sekunden
window.setInterval("bildRotationWechsle()", 5000);
}
function bildRotationWechsle () {
// bildIndex um 1 erhöhen
if (bildIndex == bilddaten.length - 1) {
// Wenn schon am Ende der bildliste, zurücksetzen und wieder von vorne anfangen
bildIndex = 0;
} else {
// Ansonsten einfach 1 addieren, um den nächsten bild zu zeigen
bildIndex++;
}
var bildLink = document.getElementById("bild-link")
bildLink.href = bilddaten[bildIndex].link;
bildLink.title = bilddaten[bildIndex].description;
var bildBild = document.getElementById("bild-bild");
bildBild.src = "bilder/orgafoto/bild" + bildIndex + ".jpg";
}
function initLightbox()
{
if (!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
anchors[i] = function() {
showLightbox(this);
return false;
}
}
</script>
Hab die Zeile von Mathias auch gleich hinzugefügt, aber leider funktioniert das irgendwie nicht :-(