tippgeber: Zufallsmusik

Beitrag lesen

<script type="text/javascript">
var witz={
liste:["Musik/Thema/Musik1.mp3","Musik/Thema/Musik2.mp3"],
auswahl:function() {
  var w=Math.floor(Math.random()*witz.liste.length);
  var ww=witz.liste[w];
  if (witz.liste.length>1) witz.liste.splice(w,1);

füge hier sowas ein:
     var krachmacher=document.getElementsByTagName("embed")[0];
     if (krachmacher) krachmacher.src=ww;
denn woher soll embed sonst wissen, was gespielt werden soll? Eine Datei namens "witzplatz" wird es wohl nicht geben.

var witzplatz=document.getElementById("witzplatz");
  if (witzplatz) {

hier fehlt ein bisschen Stringverarbeitung um den Titel zu extrahieren. Ein Tipp wäre lastIndexOf()

if (!witzplatz.firstChild) witzplatz.appendChild(document.createTextNode(ww));
   else witzplatz.firstChild.data=ww;
  }
},
init:function() {
  var witzplatz=document.getElementById("witzplatz")
  if (witzplatz) witzplatz.onclick=witz.auswahl;
}
}
window.onload=function() {
witz.init();
witz.auswahl();
}
document.write('<div id="witzplatz"></div>')
document.write('<embed src="witzplatz" volume="0" width=280 height=45 autostart=true>')
</script>