JavaScript and client side scripting.
Moderator: General Moderators
mesz
Forum Contributor
Posts: 216 Joined: Fri May 23, 2003 8:11 am
Location: M/cr
Post
by mesz » Sat Nov 08, 2003 8:26 am
Building a site for a mate as a favour. I did get a onMouseOver hover sound to work then lost the file!
This will now not work but should! I think I'll die before I solve this...please please help!!!
In the
head section
Code: Select all
<script type="text/javascript">
<!--
var tmr = null, ebd = null;
function makeSound(file) {
if (!ebd) {
var snd = document.createElement('embed');
snd.setAttribute("name", "hoversound");
snd.setAttribute("id", "hoversound");
snd.setAttribute("src", "file");
snd.setAttribute("autostart", "true");
snd.setAttribute("loop", "true");
snd.setAttribute("volume", "150");
snd.setAttribute("hidden", "true");
document.getElementById("sound-holder").parentNode.appendChild(snd);
if (tmr) {
clearTimeout(tmr);
}
tmr = setTimeout('killSound()', 2000);
ebd = true;
}
else {
clearTimeout(tmr);
killSound();
return makeSound(file);
}
}
function killSound(){
document.getElementById("sound-holder").parentNode.removeChild(document.embedsї'hoversound']);
emd = null;
}
//-->
</script>
In the
body section:
Code: Select all
<span id="sound-holder">
<a href="http://www.unitedartcity.co.uk/phpBB2/index.php" onMousOver="makeSound('amazing.wav');">
test</a>
</span>
evilMind
Forum Contributor
Posts: 145 Joined: Fri Sep 19, 2003 10:09 am
Location: Earth
Post
by evilMind » Sat Nov 08, 2003 4:02 pm
If your doctype is xhtml then you might need to change the "autostart" attribute to "autostart". (as well as for "loop" and "hidden")
ex:
Code: Select all
snd.setAttribute("autostart", "autostart");
snd.setAttribute("loop", "loop");
snd.setAttribute("hidden", "hidden");
also try changing onMouseOver to onmouseover (all lower case)
It seems that the boolean values true|false are not recognized... This may give you a little insight (although, I swore i had a better link around here somewhere.)
http://www.w3.org/TR/xhtml1/#C_10
...
...
This may also be of use:
http://www.w3.org/TR/xhtml1/#h-4.5
mesz
Forum Contributor
Posts: 216 Joined: Fri May 23, 2003 8:11 am
Location: M/cr
Post
by mesz » Mon Nov 10, 2003 6:51 am
Cheers for the response - did not work..however neither have a dozen seperate approaces. Sounds work onLoad, when embedded for autostart, but no onmouseover sounds work....I don't think this can be a widley supported technology.
Truly driving me mad...doing this for free and its become an all consuming obsession!