Hi.
I have run into a strange problem with the "Random Background Music" script.
See, I have modified it a little bit because I need it to play .wav sound effects. -Which is not a problem at all - it does that perfectly...
The problem arise when I try to run it after a timed delay, using "setTimeout" or "setInterval": After the preset delay the function then runs a single time at which point the browser stops working:
The page don't autoreload (as it's supposed to if I use the "setTimeout" solution). - Rightclick don't work until I reload manually. - And when I reload (or does anything else on the toolbar) the page goes blank. It does play the soundfile when I refresh manually though, but without the delay.
Having tested a bit it seems there is no problem with running the function as such. No problem there. - It is only when I try to run it after a delay...
Can anybody please help me with this? - (It's propably my bad cos I dont have much of the first clue on java. I know, I know).
--
Here is the full code - Try it and you'll see what I mean:
<head>
<script language="JavaScript">
<!--
//By JavaScript Kit (http://www.javascriptkit.com) More JavaScripts here!
function play()
{
var sound1="audio/01.wav"
var sound2="audio/02.wav"
var sound3="audio/03.wav"
var sound4="audio/04.wav"
var sound5="audio/05.wav"
var x=Math.round(Math.random()*4)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else x=sound5
if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+x+'"'+' loop="no">')
else
document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0" volume="2" width="20"
height="20" autostart="true" loop="false">')
}
-->
</script>
</head>
<body background="testimage.jpg">
<script>
setInterval("play()",1500)
</script>
</body>
-----
Ups.. Just realize that it wasn't a script here from DynamicDrive.. Oh well.. That doesn't mean you can't have an opinion on the problem anyways...
- Also just discovered another thing: After I reload the page and can use rightclick again: If I then choose "Show source" from the right-click menu all I get is a blank document containing nothing but one statement: <bgsound src="audio/01.wav" loop="no">
That would sort of explain the blank page and why there is no functionality etc... But WHAT THE... ???!!!



Reply With Quote

lol.


Bookmarks