onMouseOver sound not working for some mystery reason

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
mesz
Forum Contributor
Posts: 216
Joined: Fri May 23, 2003 8:11 am
Location: M/cr

onMouseOver sound not working for some mystery reason

Post by mesz »

Building a site for a mate as a favour. I did get a onMouseOver hover sound to work then lost the file! :evil: 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) &#123;
if (!ebd) &#123;
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) &#123;
clearTimeout(tmr);
&#125;
tmr = setTimeout('killSound()', 2000);
ebd = true;
&#125;
else &#123;
clearTimeout(tmr);
killSound();
return makeSound(file);
&#125;
&#125;
function killSound()&#123;
document.getElementById("sound-holder").parentNode.removeChild(document.embeds&#1111;'hoversound']);
emd = null;
&#125;
//-->
</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 »

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
User avatar
mesz
Forum Contributor
Posts: 216
Joined: Fri May 23, 2003 8:11 am
Location: M/cr

Post by mesz »

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!
Post Reply