Trying to play wav file when img or button clicked
Hi everybody, I just registered here tonight.
I'm having a problem that I thought would be simple, but it's driving me crazy!
I simply want to play a short .wav sound when a button or image is clicked. I have one that plays once when the page opens, but I don't want that. I want the sound to wait for the OnClick.
This script I have looks right, but I'm new and don't fully understand how to go about this. If anyone would help me out here, I would solve the Middle East trouble, eliminate the National debt, and find jobs for all the unemployed!
Thanks for any guidance, JD ps. I use Chrome & IE
------------------------------------------------------------------------
<style type="text/javascript">
<script>
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.Play();
}
</script>
<!-- sound file is laugh.wav ,it is in the same folder as this page ( /pages/pgtest9.html )--!>
</body>
</html>
************************************************************************************
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SIMBAR={5DC47607-819F-11DF-897C-00904BDA636E}; GTB6.6; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; yie8; AskTbNG2V5/5.9.1.14019)
Timestamp: Sat, 12 Feb 2011 08:27:55 UTC
function playme (url){
var audio=document.createElement("audio");
audio.src=url;
audio.play();
}
playme("http://www.nch.com.au/acm/11k16bitpcm.wav");
EDIT:
i went ahead and cooked up an xbrowser version that works in IE, provided they have WindowMedia installed, which should be most IE machines.
If anyone out there can improve the IE code, please post amended code.
Bookmarks