-1

Hello--
It has been a few years since I posted anything here. I developed a web site that randomly played various MP3 files I stored. I am working to rewrite some of the code because it appears if my code to do this is no longer working. Can someone please look at the code and give me some suggestions as to what I need to change or fix to get this feature working again? I hope that I am doing this right. Thank you.

<SCRIPT LANGUAGE="Javascript">

   var sound1="Great Lakes Lighthouses/MP3 Files/Sound 1.MP3"
   var sound2="Great Lakes Lighthouses/MP3 Files/Sound 2.MP3"
   var sound3="Great Lakes Lighthouses/MP3 Files/Sound 3.MP3"
   var sound4="Great Lakes Lighthouses/MP3 Files/Sound 4.MP3"
   var sound5="Great Lakes Lighthouses/MP3 Files/Sound 5.MP3"
   var sound6="Great Lakes Lighthouses/MP3 Files/Sound 6.MP3"
   var sound7="Great Lakes Lighthouses/MP3 Files/Sound 7.MP3"
   var sound8="Great Lakes Lighthouses/MP3 Files/Sound 8.MP3"
   var sound9="Great Lakes Lighthouses/MP3 Files/Sound 9.MP3"
   var sound10="Great Lakes Lighthouses/MP3 Files/Sound 10.MP3"
   var sound11="Great Lakes Lighthouses/MP3 Files/Sound 11.MP3"
   var sound12="Great Lakes Lighthouses/MP3 Files/Sound 12.MP3"
   var sound13="Great Lakes Lighthouses/MP3 Files/Sound 13.MP3"
   var sound14="Great Lakes Lighthouses/MP3 Files/Sound 14.MP3"
   var sound15="Great Lakes Lighthouses/MP3 Files/Sound 15.MP3"
   var sound16="Great Lakes Lighthouses/MP3 Files/Sound 16.MP3"
   var sound17="Great Lakes Lighthouses/MP3 Files/Sound 17.MP3"
   var sound18="Great Lakes Lighthouses/MP3 Files/Sound 18.MP3"
   var sound19="Great Lakes Lighthouses/MP3 Files/Sound 19.MP3"
   var sound20="Great Lakes Lighthouses/MP3 Files/Sound 20.MP3"
   var x=Math.round(Math.random()*19)

   if (x==0) x=sound1
    else if (x==1)  x=sound2
    else if (x==2)  x=sound3
    else if (x==3)  x=sound4
    else if (x==4)  x=sound5
    else if (x==5)  x=sound6
    else if (x==6)  x=sound7
    else if (x==7)  x=sound8
    else if (x==8)  x=sound9
    else if (x==9)  x=sound10
    else if (x==10) x=sound11
    else if (x==11) x=sound12
    else if (x==12) x=sound13
    else if (x==13) x=sound14
    else if (x==14) x=sound15
    else if (x==15) x=sound16
    else if (x==16) x=sound17
    else if (x==17) x=sound18
    else if (x==18) x=sound19
    else x=sound20

if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+x+'"'+' loop="2">')
else 
   document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')

  </script>
2
Contributors
4
Replies
32
Views
3 Years
Discussion Span
Last Post by AQWst
-1
/unknown/i.test(document.createElement('bgsound')) ?
document.write("<embed src='"+x+"' hidden autostart loop>") :
document.write("<bgsound src='"+x+"' loop>");
-1

I am still a bit confused..Do I replace my code in lines 46-49 with this or what? Can you please give me a better explanation?

Votes + Comments
We can all see that
0

Yes, it's a an obvious replacement of your old long working but recently failing part of the script.

And thank you for downvoting. My fault...

Edited by Troy III

-1

This is still not working..should I repost this question with my complete code rather than the short piece I thought was needed to solve this problem?

Votes + Comments
it is working
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.