1

hello i am abit new in client side programming and html, i am trying to excute the following line in firefox and other browsers , the code should play a sound, problem is that the code works and play the sound on IE and Chrome but not on firefox here is my code:

<!DOCTYPE html>
<html>

<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>Untitled 1</title>
    <script type="text/javascript">
       function playsound()
       {
       var sound= document.getElementById("check");
       sound.play();
       }
    </script>
</head>

<body>
<audio id = "check" preload = "auto">
    <source src = "check.mp3" type = "audio/mpeg"></audio>

<input type="button" onclick="playsound()" value="play">

4

2 に答える 2

2

Firefox doesn't support the MP3 format as audio source. If you add a second source file in OGG format, the script should work in Firefox too. See this Link for more info

于 2012-04-20T06:25:25.883 に答える
1

The fact is that firefox and opera do not support mp3 files in html5 audio tag. You can check supported browser in w3schools. Its work around is that you need a fallback flash audio player.

于 2012-04-20T06:26:29.253 に答える