Mac Discussion

Get help with your Mac hardware and software. Discuss Apple and its products.

[Advanced]
Jump To:

Goto Thread: PreviousNext
javascript or css sound buttons?
Posted by: jaz (IP Logged)
Date: January 18, 2007 10:08AM

I am trying to add start and stop sound buttons to web pages and am having problems playing them on Macs. I have tried several Javascripts that use the "embed" tag and background sound which seem to work well on PCs, and sometimes on Macs. Safari is the biggest problem, but one friend testing it had problems using Firefox on his Mac. In all cases the on button works, but the off button doesn't work with Safari and his Firefox.

The script I have found to be the best so far is:

-----------------------------------------------------

<script language="JavaScript">
function DHTMLSound(surl) {
document.getElementById("dummyspan").innerHTML=
"<embed src='"+surl+"' hidden=true autostart=true loop=false>";
}

function SoundOff(surl) {
document.getElementById("dummyspan").innerHTML=
"<embed src='"+surl+"' hidden=true autostart=false loop=false>";
}

</script>

---------------

<body>

<!--***********Sound buttons************-->
<span id=dummyspan></span><form>
<input type="button" value="Play Sound" onClick="DHTMLSound('soundTest.mp3')">
<input type="button" value="Stop Sound" onClick="SoundOff('soundTest.mp3')">
</form>
<!--*******End Sound buttons**********-->
</body
--------------------------------------------------------

I would like to do it with just Javascript and or CSS.

Thanks.



Sorry, only registered users may post in this forum. Click here to register now.
Page creation time: 1265745289.54 sec.