Script to play random background sound on each page opening?
-
Hi, all.
I am making a light-hearted comedy/musical site. I want a random sound file to play every time a new page or single post page or opens up (like Homer Simpson saying D’ope, or More Cowbell, etc.).
How could I do this?
I know how to make one play:
if (navigator.appName == "Microsoft Internet Explorer") { document.write('<bgsound src="https://startupselling.com/natestest/wp-content/uploads/igottahavemorecowbellbaby.wav" loop="false">'); } else { document.write('<embed type="application/x-mplayer2" pluginspage="https://www.microsoft.com/Windows/MediaPlayer/" name="MediaPlayer" src="https://startupselling.com/natestest/wp-content/uploads/igottahavemorecowbellbaby.wav" autostart="true" showstatusbar="0" showcontrols="0" showdisplay="0" volume="1" height="1" width="1" loop="false"><br />'); }
Then paste this into the page:
<script type="text/javascript" src="https://startupselling.com/natestest/wp-content/uploads/morecowbell.js"></script> <script type="text/javascript"> <!-- updatepage(); //--></script>
But I really know nothing about JavaScript arrays, which I’m pretty sure is what I need here.
It might also be good to know how to use a custom field to do it, that way the sound bites wouldn’t need to be random, I could put a sound bite on a page that is related to that page.
Thanks in advance!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Script to play random background sound on each page opening?’ is closed to new replies.